adamriley Posted December 24, 2009 Share Posted December 24, 2009 Hi could someone please tell me if there is a way to show a parameter in the url for example the url of a file is sitemap.html?name=nathanw and then the browser would write nathanw Link to comment https://forums.phpfreaks.com/topic/186283-url-parameters/ Share on other sites More sharing options...
rajivgonsalves Posted December 24, 2009 Share Posted December 24, 2009 not perfect but works <script> function getParam(name) { var url = location.href; if (url.indexOf('?') !== -1) { var query = url.substring(url.indexOf('?')+1, url.length); parts = query.split('&'); for(i=0;i<parts.length;i++) { eachpart = parts[i].split("="); if (eachpart[0] == name) { return eachpart[1]; } } } } document.write(getParam('name')); </script> Link to comment https://forums.phpfreaks.com/topic/186283-url-parameters/#findComment-983806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.