<script> function getURLParameter(name) { return decodeURI( (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || '' ); } </script> <script>document.write(getURLParameter("brand") + (" ") + getURLParameter("model"))</script> 

I use this option. The url displayed, but does not display on the page.

  • show an example of Url to complete the picture - Ivan Pshenitsyn

1 answer 1

Question and question code do not match each other. The definition of the phone model - through which the user sits, is another You rather - how to display the parameters from the address bar.

So document.write is a very bad way to modify a document, try to output it to an element on a page: suppose the page exists

 <div id="elementToModelOutput"></div> 

then such a script will output the necessary parameters to it.

 document.addEventListener("DOMContentLoaded", function(event) { document.getElementById("elementToModelOutput").innerHTML = getURLParameter("brand") + " " + getURLParameter("model"); }); 

But I note - it is not safe to output this way. the address parameter may contain a script - and the evilman, throwing such a link to the "admin" can drag off his account - XSS vulnerability.