How to read the contents of the address bar after '?' mean and embed value in HTML?

I am redirecting from some page to index.html. The page redirects to the index using the following address in the address bar: http://localhost/index.html?page.html

How can I read the value after the sign ? and paste it (page.html) into the index.html file?

+4
source share
4 answers
 var url = window.location.href; var params = url.split('?'); alert(params[1]); 
+8
source

to remove window.location.search together with substring ?

More information can be found on the link regarding the property, but regarding its listing on the page:

 <script type="text/javascript"> var GET = window.location.search.substring(1); document.write(GET); </script> 
+6
source

You can also extract it using RegExp. This may not be the perfect solution, but nonetheless:

 var url = location.href.match(/\?(.+)/)[1]; 
+1
source

Split() document.URL on lastIndexOf and parse it from there:

 var url=document.URL; var urls=url.substr(url.lastIndexOf('?')+1,url.length); console.log(urls); // urls will contain everything right of the ? 
+1
source

Source: https://habr.com/ru/post/1399288/


All Articles