Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q992 How can I accept a name/value pair in the current url and access it as a variable and value?

irt.org | Knowledge Base | JavaScript | Link | Q992 [ previous next ]

Q992 How can I accept a name/value pair in the current url and access it as a variable and value?

If the URL is something like:

http://www.irt.org/index.htm?number=5

Then the following will create a JavaScript variable called number, with the value of 5:

<script language="JavaScript"><!--
if (location.search.length > 0)
    eval('var ' + location.search.substring(1));
//--></script>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.