473,387 Members | 3,750 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,387 software developers and data experts.

window.location not working in IE

mikewagan
hello guys, Javascript's been bugging on IE, and i'm trying to search for a solution for this answer but no luck.

I have a select box as a navigation element. If a user clicks on an option, it will go to a separate page. This works well in Mozilla, but not in IE. heres my code:


[HTML]<form method="get" action="">
<select name="category" id="category">
<option value="Nature" onclick="window.location='index.php'; return true;">Nature</option>
<option value="Fine_Arts" selected="selected" onclick="window.location='finearts.php'; return true;">Fine Arts</option>
<option value="People" onclick="window.location='people.php'; return true;">People</option>
<option value="Places" onclick="window.location='places.php'; return true;">Places</option>
<option value="Fashion" onclick="window.location='fashion.php'; return true;">Fashion</option>
<option value="Street_Photography" onclick="window.location='streetphotography.php'; return true;">Street Photography</option>
<option value="Photojournalism" onclick="window.location='photojournalism.php'; return true;">Photo Journalism</option>
<option value="Photojournalism" onclick="window.location='gallery.php'; return true;">Gallery</option>

<option value="Photojournalism" onclick="window.location='specialevents.php'; return true;">Special Events</option>
<option value="Photojournalism" onclick="window.location='amateurphotography.php'; return true;">Amateur Photography</option>
<option value="Photojournalism" onclick="window.location='blackandwhite.php'; return true;">Black & White Photography</option>
</select>
</form>[/HTML]


Any help is appreciated!
Feb 5 '08 #1
6 2307
acoder
16,027 Expert Mod 8TB
Instead of an onclick for each option, add an onchange to the select object to call a function which takes the value and sets the location.href to that.
Feb 5 '08 #2
Instead of an onclick for each option, add an onchange to the select object to call a function which takes the value and sets the location.href to that.
here's what i did:

<option value="Fine_Arts" onchange="window.location='finearts.php'; return true;">Fine Arts</option>

instead of

<option value="Fine_Arts" onclick="window.location='finearts.php'; return true;">Fine Arts</option>

but did not fix the problem with IE.
Feb 5 '08 #3
mrhoo
428 256MB
IE expects the onchange to come from the select element, not the option.
The select elements value will be the selected option's value.

This works as well in firefox as listening to each option.
.
Feb 5 '08 #4
acoder
16,027 Expert Mod 8TB
In code, that would be:
Expand|Select|Wrap|Line Numbers
  1. <select name="category" id="category" onchange="location.href=this.value;">
  2. <option value="index.php">Nature</option>
  3. <option value="finearts.php">Fine Arts</option>
  4. <option value="people.php">People</option>
and so on.
Feb 5 '08 #5
In code, that would be:
Expand|Select|Wrap|Line Numbers
  1. <select name="category" id="category" onchange="location.href=this.value;">
  2. <option value="index.php">Nature</option>
  3. <option value="finearts.php">Fine Arts</option>
  4. <option value="people.php">People</option>
and so on.
Thanks a lot man! It works for me!
Feb 5 '08 #6
acoder
16,027 Expert Mod 8TB
You're welcome. Post again if you have any more questions.
Feb 6 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to...
2
by: venkatesh | last post by:
Hi Members, I have used the below mentioned code to open a html page in a new browser. The window size is 200 x 300. In that browser, I've given code to open another browser of the same size....
1
by: Tersia Ehlert | last post by:
Hi I have an .NET web application where I redirect a page on submit to a blank page where the code below runs client side. I want to, with this code, refresh two frames - the one my page was...
5
by: spam_me_ not | last post by:
I already understand that one cannot disable a browser's forward and back functions. This is a situation where I have code working in Mozilla V1.6 and would like something similar for Opera and...
2
by: voodoolv | last post by:
So.. I have a javascript that makes a popup with a javscript function in it. The function in the popup after 5 seconds tries to change the "price" field value in the opener window: sourze=...
2
by: Dennis Ålund | last post by:
Is it possible to notice a change of window.location.hash without polling? I'm working on a Ajax-platform (yes, inventing the wheel again) and have finished almost everything except the support...
8
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript"...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
1
by: vinpkl | last post by:
hi all i have two dynamic drop downs of dealer id and category id which work properly with window.location var dealerid; function getList(xyz) {...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.