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! Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.