wispas Posted September 10, 2010 Share Posted September 10, 2010 I have a page with a link: <a href="grab.html?myParameter=hotel">Show me the Parameter</a> On 'grab.html' i want to display the 'myParameter' prameter which should be "hotel" Can anyone show me howi can display the parameter from the URL please. Thanks! Link to comment https://forums.phpfreaks.com/topic/213054-displaying-url-parameters/ Share on other sites More sharing options...
Adam Posted September 10, 2010 Share Posted September 10, 2010 There's no native support for this in JavaScript, however it has a property within the window.location object called search. You can use regex to match() and return the needed part of the string: var myParameter = window.location.search.match(/myParameter\=([^&]+)/)[1]; If this is something you plan to use multiple times I'd convert it into a function. Link to comment https://forums.phpfreaks.com/topic/213054-displaying-url-parameters/#findComment-1109582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.