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
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?
?
var url = window.location.href; var params = url.split('?'); alert(params[1]);
to remove window.location.search together with substring ?
window.location.search
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>
You can also extract it using RegExp. This may not be the perfect solution, but nonetheless:
var url = location.href.match(/\?(.+)/)[1];
Split() document.URL on lastIndexOf and parse it from there:
Split()
document.URL
lastIndexOf
var url=document.URL; var urls=url.substr(url.lastIndexOf('?')+1,url.length); console.log(urls); // urls will contain everything right of the ?
Source: https://habr.com/ru/post/1399288/More articles:css display: what? - arrange boxes one by one - cssWhat type of "assert" should rspec use to verify prerequisites? - ruby-on-rails"Unhandled event Loop Exception" when executing something in Android XML - androidEmbedding a loop tag in Handlebars.js - javascriptRuby Hash Initializers - ruby ââ| fooobar.comhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1399289/how-can-i-check-if-the-current-window-is-top-or-parent-via-php&usg=ALkJrhjgTpCdU4ii_cKaRnlgfIJ4BJ4t0QOrganizing various queries in Node.js - javascriptIPad canvas flicker when using - ipadGraphic tool: how to access properties? - pythonRounding up inaccuracies when combining areas in Java? - javaAll Articles