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

Q1428 Is there any way to intercept a URL and add some more parameters to the search string?

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

If it is a form submission then:

<script language="JavaScript"><!--
function intercept() {
    document.myform.parm1 = 'value1';
    document.myform.parm2 = 'value2';
}
//--></script>

<form name="myform" onsubmit="intercept()">
<input type="hidden" name="parm1">
<input type="hidden" name="parm2">
<input type="submit">
</form>

If it is a link then:

<script language="JavaScript"><!--
function intercept(what) {
    what.href += '&parm1=value1&parm2=value2';
}
//--></script>

<a href="alink.href?existing_parm=existing_value" onClick="intercept(this)">text link</a>

©2018 Martin Webb