简体   繁体   中英

JavaScript - Get url from window without submitting it

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM