FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Script doesnt work in Internet Explorer

   
Author Topic: Script doesnt work in Internet Explorer
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.
IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
Also my IE is version 6.
IP: Logged | Report this post to a Moderator
scifibum
Member
Member # 7625

 - posted      Profile for scifibum   Email scifibum         Edit/Delete Post 
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 ]

Posts: 4287 | Registered: Mar 2005  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.
IP: Logged | Report this post to a Moderator
King of Men
Member
Member # 6684

 - posted      Profile for King of Men   Email King of Men         Edit/Delete Post 
Put in some debug outputs to see if the script starts up at all.
Posts: 10645 | Registered: Jul 2004  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
It doesn't appear to be, alert doesn't work when its within it.
IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.
IP: Logged | Report this post to a Moderator
King of Men
Member
Member # 6684

 - posted      Profile for King of Men   Email King of Men         Edit/Delete Post 
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.
Posts: 10645 | Registered: Jul 2004  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.
IP: Logged | Report this post to a Moderator
scifibum
Member
Member # 7625

 - posted      Profile for scifibum   Email scifibum         Edit/Delete Post 
"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.

Posts: 4287 | Registered: Mar 2005  |  IP: Logged | Report this post to a Moderator
King of Men
Member
Member # 6684

 - posted      Profile for King of Men   Email King of Men         Edit/Delete Post 
quote:
I tried everything I could think of
There, fixed that for you. Think some more.
Posts: 10645 | Registered: Jul 2004  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.
IP: Logged | Report this post to a Moderator
scifibum
Member
Member # 7625

 - posted      Profile for scifibum   Email scifibum         Edit/Delete Post 
There's definitely a way to make that work. Do you know how to set attributes on the page elements.
Posts: 4287 | Registered: Mar 2005  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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"
IP: Logged | Report this post to a Moderator
scifibum
Member
Member # 7625

 - posted      Profile for scifibum   Email scifibum         Edit/Delete Post 
http://www.w3.org/TR/html401/interact/forms.html#edef-OPTION
Posts: 4287 | Registered: Mar 2005  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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?
IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
Can what you suggest be done without radically rewriting what I've done?
IP: Logged | Report this post to a Moderator
scifibum
Member
Member # 7625

 - posted      Profile for scifibum   Email scifibum         Edit/Delete Post 
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.

Posts: 4287 | Registered: Mar 2005  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.
IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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.

IP: Logged | Report this post to a Moderator
scifibum
Member
Member # 7625

 - posted      Profile for scifibum   Email scifibum         Edit/Delete Post 
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.)

Posts: 4287 | Registered: Mar 2005  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
Yes but I'm hoping to do whatever it is I need doing with minimal modifications.
IP: Logged | Report this post to a Moderator
scifibum
Member
Member # 7625

 - posted      Profile for scifibum   Email scifibum         Edit/Delete Post 
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.
Posts: 4287 | Registered: Mar 2005  |  IP: Logged | Report this post to a Moderator
Lisa
Member
Member # 8384

 - posted      Profile for Lisa   Email Lisa         Edit/Delete Post 
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.
Posts: 12266 | Registered: Jul 2005  |  IP: Logged | Report this post to a Moderator
Lisa
Member
Member # 8384

 - posted      Profile for Lisa   Email Lisa         Edit/Delete Post 
Oh, you'll probably want to add a line that says if obj.value is "" to exit the function. Forgot about that.
Posts: 12266 | Registered: Jul 2005  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
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=
IP: Logged | Report this post to a Moderator
theamazeeaz
Member
Member # 6970

 - posted      Profile for theamazeeaz   Email theamazeeaz         Edit/Delete Post 
quote:
Originally posted by Blayne Bradley:
Also my IE is version 6.

Clearly you like this website:

www.saveie6.com

Posts: 1757 | Registered: Oct 2004  |  IP: Logged | Report this post to a Moderator
Alcon
Member
Member # 6645

 - posted      Profile for Alcon   Email Alcon         Edit/Delete Post 
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
Posts: 3295 | Registered: Jun 2004  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

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