Change/Redirect page via JavaScript

Had 2 dig 2 (re)discover how to send t/browser 2 another page:
1)  Don’t need a <FORM> tag!
2)  Ended up doing the following in a SELECT dd-list:  (The key is “self.location.href”)!!!


I took this one step further to use js to submit a form by clicking a link rather than pressing a button:

<FORM NAME=”search” METHOD=”POST” ACTION=”/cgi-bin/search” TARGET=”c”>

<A href=”index.html” onClick=”; return false” target=”c”>Search for:

<BR><INPUT NAME=”srch_query” TYPE=”TEXT” SIZE=”10″>


In this case, if abUser has javascript off, clicking link goes to “index.html”. If js is on, the form is submitted and the value typed into “srch_query” is sent. I use “index.html” as a “search page” that the js-less abUser can type in his search query and press a button to do the search. The user w/js on will also get this screen from the “search” script, if nothing is typed into the “srch_query” box. This “search screen” also contains some “advanced search” options.

The key is the “return false”. Otherwise it seems to always go to “index.html”.


Feel Free to Comment (Name/Email/Website optional):

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: