This article describes the method of JS to obtain url parameters and main domain name. Share it for your reference, as follows:
<script>alert(location.hostname)alert(location.port)alert(location.pathname)alert(location.search)</script><script>function winsx(url) //Arguments passed by URL { var winurl =url?url:(unescape(window.location.href)); var wlp = winurl.split("?")[1]; var wincs = wlp.split("&"); for(var i=0; i<wincs.length; i++) { var tur = wincs[i].split("="); eval('this.'+tur[0]+'="'+tur[1]+'";'); }}var ug = new winsx("http://www.yourname.com/aa/bb.php?val=11&test=2");alert(ug.val)alert(ug.test)</script>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Data Structure and Algorithm Skills", "Summary of JavaScript traversal algorithms and techniques", "Summary of json operation techniques in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques" and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.