Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

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:


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));

©2018 Martin Webb