0

So I have a page that I want to retrieve the URL from but I want to get the current text that is written there regardless of if the url was submitted or not (imagine if the user entered a page and decided to change the val=sfbdjkfg directly through the url but didn't submit it )

So window.location.href is not what I want because I have to submit to get the URL

Is there any way to do this? What about using a javaScript framework that uses dynamic routes?

  • Please refer this https://stackoverflow.com/questions/6390341/how-to-detect-url-change-in-javascript – Harmandeep Singh Kalsi Feb 20 '20 at 11:02
  • @HarmandeepSinghKalsi — That doesn't help. The URL isn't changing. The question is about when the user edits the text in the address bar but never presses Enter to confirm it. – Quentin Feb 20 '20 at 11:12
  • @user1678 There's no physical ability to do this, with frameworks or not. URL input field is not a part of the page but a part of browser UI. Your app doesn't have access to browser UI, unless it's browser extension. Allowing websites to spy on client's next destination would be a major privacy and security breach. Think of it this way, as long as a user doesn't submit the address, it's none of your website's business what a user types there. – Estus Flask Feb 20 '20 at 13:31

1 Answers1

1

There's no such way via javascript to interact with browser UI components such as URL bar or "add as bookmark" button unless your browser provides that. Browser itself act as a wrapper/client that provides specific APIs and surely not to open gates to access the outside of it, for security reasons.

jrumandal
  • 115
  • 1
  • 10