Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | History | Q323 [ previous next ]

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

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.


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.