|
Q870 How can I pass a querystring parameter from a link to a function on the linked page?
irt.org | Knowledge Base | JavaScript | Link | Q870 [ previous next ]
Q870 How can I pass a querystring parameter from a link to a function on the linked page?
If you actually want to set this value to the value of a JavaScript
variable then:
<script language="JavaScript"><!--
var variableName = 'Hello world';
//--></script>
<a href="newpage.html" onClick="this.href='newpage.html?' + variableName">Linked page</a>
|
To retrieve it in newpage.html:
<script language="JavaScript"><!--
var variableName = null;
if (location.search.length > 0)
variableName = location.search.substring(1);
function functionName(text) {
alert(text);
}
functionName(variableName);
//--></script>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.