Click to See Complete Forum and Search --> : redirect the user to another page
Reham
04-21-2003, 04:55 AM
HI every one
I need to write a javascript code inside the HTMl that on click on any button. it will redirect the user to another page?
Thanks Alot
gil davis
04-21-2003, 05:48 AM
Your request is unclear. Do you want to redirect in addition to some other action? Do you want the same action on any button in a page?
Reham
04-21-2003, 05:59 AM
if you have one page "default.html" it contain a button
I want on the click event of that button to be redirect to another page "search.aspx" using java script code in the click event
Thanks
AdamGundry
04-21-2003, 06:28 AM
Remember this will fail on browsers without JS:
<input type="button" name="redirectbutton" value="Click Me" onclick="document.location = 'search.aspx'>
You might also want to check out information on the Location object:
http://developer.netscape.com/docs/manuals/communicator/jsref/wina1.htm#1012987
Adam
gil davis
04-21-2003, 07:07 AM
<input type="button" name="redirectbutton" value="Click Me" onclick="document.location = 'search.aspx'>Hey, that's pretty funny! You give the guy an IE-only solution (document.location), and then direct him to the Netscape documentation (window.location).
Charles
04-21-2003, 07:13 AM
Better yet, the following will work without JavaScript :
<form action="search.aspx">
<div><input type="submit" value="Search"></div>
</form>
or
<a href="search.aspc" title="Search"><img src="some.png" alt="Search"></a>
Adam, be careful there. The example you gave employs the location property of the document object but you have directed us to information about the location object. The two are not entirely the same. The property was depricated some time in the past century and you will note that it does not appear in the documentation that you cite (http://developer.netscape.com/docs/manuals/communicator/jsref/doc1.htm#1048486). We're supposed to be use instead window.location.
AdamGundry
04-21-2003, 10:40 AM
You're right Charles, I didn't realise document.location was deprecated. Thanks for the advice.
Adam