I wanted to do some js analytics, so I would need to know how to get whatever the user entered in the address bar as a js variable so I can know what are the most common misspellings. That way I can make redirects for the most common misspellings to the correct adresses and reduce 404 page requests.
example of user input in browser:
https://stackoverflow.com/questions
.........................................
I have tried using
document.location
but that shows what page the user is on (i.e. 404 page address), not what they have typed
Find the URL of the website.The website's URL is in the address bar, which is usually at the top of your web browser window. This bar may be at the bottom of the window in Chrome on some Androids.
1 – Select Safari from the top menu bar. 2 – Click Preferences. 3 – Select the Advanced tab. 4 – Check the box beside Show full website address.
This gives you the exact url the user is on:
document.location.href
There is no way of determining what the user typed before the request is submitted (for security-reasons).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With