This is topic Script doesnt work in Internet Explorer in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=055288

Posted by Blayne Bradley (Member # 8565) on :
 
code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=800,height=600,scrollbars=yes');
return false;
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta name="description" content="" />
<meta name="keywords" content="" />

<!-- TemplateBeginEditable name="doctitle" -->
<title>The Dept of Humanities / Philosophy / Religion - CEGEP John Abbott College</title>
<!-- TemplateEndEditable -->

<!-- TemplateBeginEditable name="head" -->

<!--Add CSS Here -->

<link href="../css/main.css" rel="stylesheet" type="text/css" />

<!-- TemplateEndEditable -->
</head>

I'm not sure how to make it compatible to IE, it works in Mozilla, but not in IE and the site that explained the code didnt offer alternate version.
 
Posted by Blayne Bradley (Member # 8565) on :
 
Also my IE is version 6.
 
Posted by scifibum (Member # 7625) on :
 
maybe you need to disable your pop up blocker in IE.

Other than that, you might want to explain what you mean by "doesn't work."

[ April 22, 2009, 01:14 PM: Message edited by: scifibum ]
 
Posted by Blayne Bradley (Member # 8565) on :
 
just does nothing, I click on the scrollbar and select and item and nothing happens no popups. It does this over several different versions of IE.
 
Posted by King of Men (Member # 6684) on :
 
Put in some debug outputs to see if the script starts up at all.
 
Posted by Blayne Bradley (Member # 8565) on :
 
It doesn't appear to be, alert doesn't work when its within it.
 
Posted by Blayne Bradley (Member # 8565) on :
 
code:
	<!-- TemplateBeginEditable name="BodyText" -->
<div id="bodytext">
<form>
<select>
<option>Please select a choice of organization</option>
<option onClick="return popup('course_organization.html', 'name')">Organized by Course Title</option>
<option>Organized by Course Number</option>
<option onClick="return popup('course_organization3.html', 'name')">Organized by Course Category</option>
</select>

</form>
</div>

Here's what im clicking.
 
Posted by King of Men (Member # 6684) on :
 
Is Javascript enabled on your browser? But seriously, this sort of debugging should be second nature for you by now. This is what programmers do all day.
 
Posted by Blayne Bradley (Member # 8565) on :
 
I tried everything, JS is enabled, popups are enabled, activeX is enabled, it WORKS IN FIREFOX it doesn't work in IE, and the site I learned the code from gave me no indication of how to make it native for IE.
 
Posted by scifibum (Member # 7625) on :
 
"It doesn't appear to be, alert doesn't work when its within it. "

This is a hint that the problem isn't with the script, it's with what is calling the script.

Are you sure the onclick event of an option is fired upon selection in all browsers?

I think you probably need to look into a handling a different event to trigger the script.
 
Posted by King of Men (Member # 6684) on :
 
quote:
I tried everything I could think of
There, fixed that for you. Think some more.
 
Posted by Blayne Bradley (Member # 8565) on :
 
quote:
Originally posted by scifibum:
"It doesn't appear to be, alert doesn't work when its within it. "

This is a hint that the problem isn't with the script, it's with what is calling the script.

Are you sure the onclick event of an option is fired upon selection in all browsers?

I think you probably need to look into a handling a different event to trigger the script.

I don't think my alternative of making it a OnChange at the select level would work as I'm manually telling it the link to each page it should go to.
 
Posted by scifibum (Member # 7625) on :
 
There's definitely a way to make that work. Do you know how to set attributes on the page elements.
 
Posted by Blayne Bradley (Member # 8565) on :
 
quote:
Originally posted by King of Men:
quote:
I tried everything I could think of
There, fixed that for you. Think some more.
There is only so much I can think of as I know virtually nothing about how JS works, just "copy and paste relevent bit of code here"
 
Posted by scifibum (Member # 7625) on :
 
http://www.w3.org/TR/html401/interact/forms.html#edef-OPTION
 
Posted by Blayne Bradley (Member # 8565) on :
 
quote:
Originally posted by scifibum:
There's definitely a way to make that work. Do you know how to set attributes on the page elements.

I don't quite assign words to what I may or may not know hence my problems with googling solutions, can you give an example of what you mean?

I use

code:
		<select>
<option>Please select a choice of organization</option>
<option onClick="return popup('course_organization.html', 'name')">Organized by Course Title</option>
<option>Organized by Course Number</option>
<option onClick="return popup('course_organization3.html', 'name')">Organized by Course Category</option>
</select>

and for a random 5-10 class in question.

code:
<select>

<select>
<option onClick="return popup('desc/AFRICA ISSUES ON DARK CONTINENT.html', 'name')" >AFRICA: ISSUES ON THE “DARK CONTINENT”</option>
<option onClick="return popup('desc/AN INTRODUCTION TO WORLD VIEW.html', 'name')" >AN INTRODUCTION TO WORLD VIEW</option>
<option onClick="return popup('desc/ASPECTS OF FREEDOM.html', 'name')" >ASPECTS OF FREEDOM</option>
<option onClick="return popup('desc/BIOETHICS.html', 'name')" >BIOETHICS</option>
<option onClick="return popup('desc/BODY-MIND.html', 'name')" >BODY-MIND</option>
<option onClick="return popup('desc/CANADA WHO NEEDS IT.html', 'name')" >CANADA WHO NEEDS IT</option>
<option onClick="return popup('desc/CANADAS DOCUMENTARY TRADITION.html', 'name')" >CANADAS DOCUMENTARY TRADITION.</option>
<option onClick="return popup('desc/CHINA AND JAPAN.html', 'name')" >CHINA AND JAPAN</option>
<option onClick="return popup('desc/COLONIZATION BY KNOWLEDGE.html', 'name')" >COLONIZATION BY KNOWLEDGE</option>
<option onClick="return popup('desc/COMMUNICATION SELF AND SOCIETY.html', 'name')" >COMMUNICATION SELF AND SOCIETY</option>

Do you mean give each one its own name which is the html link and have it redirect to its name?
 
Posted by Blayne Bradley (Member # 8565) on :
 
Can what you suggest be done without radically rewriting what I've done?
 
Posted by scifibum (Member # 7625) on :
 
Read the specification for select and option elements. The answer is there.

Hint: value

Edit to add: I could give you the answer, or you could find it pretty easily via Google, but you'd get SO MUCH MORE value out of reading some actual documentation (or even tutorials). If you aren't willing to do that, you have no business trying to be a web developer.
 
Posted by Blayne Bradley (Member # 8565) on :
 
Well I took a look at the other site.

and the question is, what exactly is wrong with my code that it works in Firefox but not in IE? Looking back at the site in question that gave me the code its popup page works

http://www.htmlcodetutorial.com/linking/linking_famsupp_72.html

in IE.

So comparing the two;

code:
<option onClick="return popup('course_organization3.html', 'name')">Organized by Course Category</option>

Mine vs his
code:
<A 
HREF="popupbasic.html"
onClick="return popup(this, 'notes')">my popup</A>

the Onclick is still there so me having it as an onclick isnt the problem so I'll see what happens if I change my code to use his method, I suspect this won't work as I probably only changed it to my way because his way didn't work.
 
Posted by Blayne Bradley (Member # 8565) on :
 
The original code itself when as a Select doesn't seem to work, but using it itself as original with only the link modifed however does work.

code:
<A HREF="course_organization.html" onClick="return popup(this, 'notes')"> my popup</A>

Click at your peril.


I can only conclude that it really does not like being an option tag or something silly of the sort.
 
Posted by scifibum (Member # 7625) on :
 
You're on the right track - the onClick event works in both browsers for the anchor element. However, if you want to use a menu instead of a series of anchor tags, you can. You have to take a different approach.

Take a look at sites that use select menus. I mean, look at their HTML. You should be able to see how to define the attributes on each option element.

If you can find a site that does something when you change the selection, even without clicking a "Submit" button, then you'll be able to see a more complete example of what you need to do. (I think Lisa's comics site she linked a couple of weeks ago does this. Aw, here I go giving it away when I promised myself I'd make you work for it.)
 
Posted by Blayne Bradley (Member # 8565) on :
 
Yes but I'm hoping to do whatever it is I need doing with minimal modifications.
 
Posted by scifibum (Member # 7625) on :
 
All the code you pasted is 'minimal'. If you have to start over it's going to be minimal work. Anyway, I'm pointing you toward something that keeps 95% of the code you've pasted into this thread.
 
Posted by Lisa (Member # 8384) on :
 
I haven't read through everything, but IE doesn't recognize events on the option tags. Just on the select. Maybe do this:
code:
<form>
<select onclick="return popup(this, 'name')">
<option value="">Please select a choice of organization</option>
<option value="course_organization.html">Organized by Course Title</option>
<option>Organized by Course Number</option>
<option value="course_organization3.html">Organized by Course Category</option>
</select>
</form>



<script type="text/javascript">
function popup(obj, windowname){
if (!window.focus) return true;
var href;
if (typeof(obj.value) == 'string') href=obj.value;
else href=obj.value.href;
window.open(href, windowname, 'width=800,height=600,scrollbars=yes');
return false;
</script>

See? Just pass the select itself in instead of the URL as a string, and replace "mylink" with the value property of the select, which is the value property of the selected option.
 
Posted by Lisa (Member # 8384) on :
 
Oh, you'll probably want to add a line that says if obj.value is "" to exit the function. Forgot about that.
 
Posted by Blayne Bradley (Member # 8565) on :
 
I had just before leaving school come up with something similar, Ill be using an onchange in the select but replacing the onclick with value=
 
Posted by theamazeeaz (Member # 6970) on :
 
quote:
Originally posted by Blayne Bradley:
Also my IE is version 6.

Clearly you like this website:

www.saveie6.com
 
Posted by Alcon (Member # 6645) on :
 
quote:
There is only so much I can think of as I know virtually nothing about how JS works, just "copy and paste relevent bit of code here"
http://www.w3schools.com/js/default.asp
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2