473,804 Members | 4,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onclick problem with netscape

if i eun this page in IE or netscape it works fine,
<select name="select" onChange="javas cript: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="javasc ript:location.h ref = select.options. value;">
</form>
thanks in advance
Jul 23 '05 #1
4 2808


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="javasc ript:location.h ref = select.options. value;">


Use
<input type="button"
onclick="window .location.href =
this.form.eleme nts.select.opti ons[this.form.eleme nts.select.sele ctedIndex].value;"
to have cross browser code.

--

Martin Honnen
http://JavaScript.FAQT s.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="javasc ript:location.h ref = 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*******@yaho o.de> wrote in message
news:41******** *************** @newsread4.arco r-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="javasc ript:location.h ref = select.options. value;">
Use
<input type="button"
onclick="window .location.href =

this.form.eleme nts.select.opti ons[this.form.eleme nts.select.sele ctedIndex].v
alue;" to have cross browser code.

--

Martin Honnen
http://JavaScript.FAQT s.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="javasc ript:location.h ref = select.options. value;">
</form>


<form>
<select id="potato">
<option value="http://example.org/">Example.o rg</option>
<option value="http://example.com/">Example.c om</option>
</select>
<input onclick="locati on.href=documen t.getElementByI d('potato').opt ions[document.getEle mentById('potat o').selectedInd ex].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.o rg</a></li>
<li><a href="http://example.com/">Example.c om</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
167448
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 I'm using on the parent page is ... <a href="#" onClick="popupcal()">choose date</a>
5
6791
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
1473
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 swithced it to "javascript:show(...);" and the code works, but I read in this group that it was not wise to do that, here's the working version, using the not recommended approach: <a href="javascript:show('art_2.jpg','600','448');" target="_self">...
4
2820
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 onClick="document.all.contents.innerHTML='<iframe width=643 height=232
2
2425
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 processing. verifyFields() is working fine and so does the history() function.
5
10889
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 works fine if I click to open in > the same window, but if I click the browser option to open in a > new window, the new window tries to open the href URL (the > onClick function does get executed, but seems to be ignored). > ...
5
1469
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 the radio button. There is not even an error message. This is a simplified version of the actual code, which is used to pass among
2
18584
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 } Which is called statically by: <button onclick="doClick(event,this);">Click me</button>
5
2596
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 is the code for this. the onclick event calls a javascript function which I put an alert in the firt line to tell me if its working. It does work in IE. Any ideas on how to get netcrap... oops, I'm sorry, netscape to fire the onclick event? ...
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10593
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9163
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.