4 ms·
It's pretty common to do this using the URI fragment in a link. For example: https://themeasureofaplan.com/market-timing/#initialContributionInput=20000&monthl
by getToTheChopin 4y ago
It's pretty common to do this using the URI fragment in a link.
For example: https://themeasureofaplan.com/market-timing/#initialContributionInput=20000&monthlyContributionInput=1000&gapToATHInput=25&cashInterestRateInput=2&tradingTransactionFeeInput=0&minYear=1993&maxYear=2023 https://themeasureofaplan.com/market-timing/#initialContribu...
This shows the performance of a market timing strategy on the S&P500, where you invest $20,000 upfront and $1,000 per month thereafter, while only buying when the market is 25%+ away from the all-time high price (analysis from 1993 to 2023).
These user input variables are all directly encoded in the URL, after the # symbol.
- iLoveOncall 4y agoThis is a terrible example though, there is no reason why those shouldn't be normal query parameters.
- getToTheChopin 4y agoI don't see why normal query parameters (using ? symbol) would be better than putting the key/value pairs after a # symbol. They both achieve the purposes of allowing custom URLs that bring the user to a specific state of the app.
- wildrhythms 4y agoAn often unintended side effect of using the URL hash to contain state is that it breaks potentially linking to an anchor element ID somewhere in the page. Obviously this doesn't matter much if the page doesn't use anchor IDs or you don't intend on users doing that.
- nimzoLarsen 4y agoInteresting. Just to make sure I understand — that url contains all of the IDs and user inputs, and then you parse out of the key/value pairs and feed those inputs into the app?
- getToTheChopin 4y agoYep. See here for an explanation: https://stackoverflow.com/questions/12520124/parse-url-fragment-with-javascript https://stackoverflow.com/questions/12520124/parse-url-fragm... Edit: better link to explain the concept