473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

onclick problem with netscape

if i eun this page in IE or netscape it works fine,
<select name="select" onChange="javascript:location.href =
this.options[selectedIndex].value;">
<option value="[url to load]" >this page </option>
<option value="[url to load]" >another page</option>
</select>
but i would rather have a button for the user to click rather than an
onchange
so i modified it to the below - it works in IE but not in netscape, any idea
why this is

<form name= "form">
<select name="select" >
<option value="[url to load]" >this page </option>
<option value="[url to load]" >another page</option>
</select>
<input type="button" name="but" value="load"
onclick="javascript:location.href = select.options.value;">
</form>
thanks in advance
Jul 23 '05 #1
4 2790


chris wrote:

but i would rather have a button for the user to click rather than an
onchange
so i modified it to the below - it works in IE but not in netscape, any idea
why this is

<form name= "form">
<select name="select" >
<option value="[url to load]" >this page </option>
<option value="[url to load]" >another page</option>
</select>
<input type="button" name="but" value="load"
onclick="javascript:location.href = select.options.value;">


Use
<input type="button"
onclick="window.location.href =
this.form.elements.select.options[this.form.elements.select.selectedIndex].value;"
to have cross browser code.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
chris wrote:
so i modified it to the below - it works in IE but not in netscape, any <input type="button" name="but" value="load"
onclick="javascript:location.href = select.options.value;">


Most browsers do not create global variables referencing named elements on
the page.

Your entire approach to this problem is fairly poor though, have a read of:
http://www.cs.tut.fi/~jkorpela/forms/navmenu.html (as you don't want the
onchange bits, you can just delete that attribute entirely from the example
code).
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #3
thanks that worked

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:41***********************@newsread4.arcor-online.net...


chris wrote:

but i would rather have a button for the user to click rather than an
onchange
so i modified it to the below - it works in IE but not in netscape, any idea why this is

<form name= "form">
<select name="select" >
<option value="[url to load]" >this page </option>
<option value="[url to load]" >another page</option>
</select>
<input type="button" name="but" value="load"
onclick="javascript:location.href = select.options.value;">
Use
<input type="button"
onclick="window.location.href =

this.form.elements.select.options[this.form.elements.select.selectedIndex].v
alue;" to have cross browser code.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #4
chris wrote:
<form name= "form">
<select name="select" >
<option value="[url to load]" >this page </option>
<option value="[url to load]" >another page</option>
</select>
<input type="button" name="but" value="load"
onclick="javascript:location.href = select.options.value;">
</form>


<form>
<select id="potato">
<option value="http://example.org/">Example.org</option>
<option value="http://example.com/">Example.com</option>
</select>
<input onclick="location.href=document.getElementById('po tato').options[document.getElementById('potato').selectedIndex].value;">
</form>

But this is a *really* bad idea because:

- it means that people who have Javascript disabled (about 1 in 10) are
unable to use your navigation system; and

- search engines don't fill in forms so won't be able to crawl your site.

A much better way of doing it is:

<ul>
<li><a href="http://example.org/">Example.org</a></li>
<li><a href="http://example.com/">Example.com</a></li>
</ul>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jez | last post by:
Hi, I've created a function which opens a popup window containing a calendar. When a day is clicked, the date is entered into a text box on the parent page and the popup is closed. The link...
5
by: Sumaira Maqsood Ali | last post by:
hi, I wanted to know if OnClick can be used outside forms also? like can plain text have the OnClick event handler associated with it? thanks Sumaira
2
by: mscir | last post by:
I was calling a function in a js file from an image onClick event, but someone still using Netscape 4 (!) complained that it didn't work. I read that img onClick doesn't work in Netscape 4, so...
4
by: Jon | last post by:
Hi, I have an iframe in a cell: <td id="contents" width="643"> <iframe width="643" height="232" src="home.asp" frameborder="0" scrolling="no"></iframe> </td> <td...
2
by: kelvin | last post by:
Hi, I've this piece of code which does not work at all. Can anyone point out my mistake? I've 2 buttons. History button will call verifyFields() function and lead to different page for...
5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
5
by: Gerard van Wilgen | last post by:
I noticed that the following line of code works in IE 6 but not in Netscape 7.1: <INPUT TYPE="radio" NAME="selComb" VALUE="0" ONCLICK="alert(selComb.value)"> Nothing happens when I click on...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
5
by: moondaddy | last post by:
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and perhaps other browsers for all I know...). Below...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.