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

Q323 Is it possible to combine forms and replace() so that the form submission does not create a history entry?

You are here: irt.org | FAQ | JavaScript | History | Q323 [ previous next ]

Not if you want to use a method="POST". If however you are using method="GET", then we could possibly rewrite the form so that it doesn't use the action and method attributes but just changes the location using JavaScript, but with the form name-value pairs tacked on the end as if we had sent the form using method="GET":

<SCRIPT LANGUAGE="JavaScript"><!--
function sendform() {
    if (document.images)
        location.replace('http://www.somewhere.com/test.cgi' + '?' + 'myText=' + escape(document.myForm.myText.value));
    else
        location.href = 'test.cgi' + '?' + 'myText=' + escape(document.myForm.myText.value);
    return false;
}
//--></SCRIPT>

<FORM NAME="myForm" onSubmit="return sendform()">
<INPUT TYPE="TEXT" NAME="myText" VALUE="sample">
<INPUT TYPE="SUBMIT" VALUE="send">
</FORM>

Note: in Opera replace() will work, but only with absolute URL's.

©2018 Martin Webb