Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Link | Q992 [ previous next ]

If the URL is something like:

http://www.irt.org/?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>

©2018 Martin Webb