Forum Moderators: open

Message Too Old, No Replies

IE not handling multiple javascript events

onmouseover and onclick in the same line

         

jonwald

10:43 pm on Apr 25, 2005 (gmt 0)

10+ Year Member



Hi everybody,

Any thoughts on this one? For some reason, the following lines work perfectly in Safari and Firefox, but not IE. In IE the window.open command works, but the link doesn't change color. Unfortunately I can't put the link color change in the style sheet because there's already a different link color change in the style sheet.

Thanks!

<DIV class="dynamic-style-3">
<SPAN class="dynamic-style-4">
<a onclick="window.open('noises-program-800.htm’,'jonathanwald','left=30,top=0,scrollbars=no,fullscreen=yes’)” onmouseout="this.style.color='black'" onmouseover="this.style.color='#FF7B1F'">Noises Off!</a>
<BR>
</DIV>
</SPAN>

Bernard Marx

10:50 pm on Apr 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unfortunately I can't put the link color change in the style sheet because there's already a different link color change in the style sheet.

?

Give your link a class name, and assign a different :hover rule.
Scripting isn't needed.
(PS The span & div are improperly nested)

ajkimoto

10:57 pm on Apr 25, 2005 (gmt 0)

10+ Year Member



As Bernard Marx just said (darn it, beat me to it!):

You can have different hover characteristics for different links. See below:

<style type="text/css">
a{
color:#808080;
text-decoration:none;
}

a:hover{
color:#d0d0d0;
text-decoration:underline;
}

.link2 {
color:#000080;
font-weight: bold;
text-decoration:none;
}

.link2:hover{
color:#ff0000;
text-decoration:underline;
}
</style>

</head>

<body>
<div id="mydiv"><a href="javascript:void(0)">Click Me!</a></div>
<a class="link2" href="javascript:void(0)">Click Me Too!</a>
</body>

jonwald

12:46 am on Apr 26, 2005 (gmt 0)

10+ Year Member



thanks to you both - once again this forum is making my life much easier!

Jonathan

jonwald

1:23 am on Apr 26, 2005 (gmt 0)

10+ Year Member



Oops, I spoke to soon. I must be using the code you suggested incorrectly, 'cause it's not working. Take a look?

<STYLE type="text/css">
<!--
A:link {text-decoration: none; color:black}
A:visited {text-decoration: none; color:black}
A:hover {text-decoration: none; color:#FF7B1F}
.link2: {text-decoration: none; color:white;}
.link2:hover {text-decoration: none; color:black;}
.link2:visited {text-decoration: none; color:white;}
.link3: {text-decoration: none; color:black;}
.link3:hover {text-decoration:none; color:#FF7B1F;}
.link3:visited {text-decoration: none; color:black;}

-->
</STYLE>

<BODY>
<DIV class="DIVProgramParaStyle">
<SPAN class="dynamic-style-1">
<a class=”link2” href="noises-program.htm" target="_blank" style="text-decoration: none">program</a>
</SPAN>
</DIV>

<DIV class="dynamic-style-3">
<SPAN class="dynamic-style-4">

<a class=”link3” onclick="window.open('noises-program-800.htm','jonathanwald','left=30,top=0,scrollbars=no,fullscreen=yes')" style="text-decoration: none">Noises Off!</a>
</DIV>
</SPAN>

Bernard Marx

9:14 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need the selector to be connected to an A for IE

A.link2:hover

etc

jonwald

6:47 am on Apr 27, 2005 (gmt 0)

10+ Year Member



Hey Bernard thanks for catching that, but it's still not working completely. It works in Safari and Mozilla, but not in IE. Is there some conflict between onclick and this use of the class tag?

The page in question is:

[jonathanwald.com...]

Thanks,

Jonathan

ajkimoto

2:20 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



Jonathan,

Okay, here are some fixes that work in IE and Firefox at least:

1. Add an href to your links in order for the hover to work. Since you are using the link to run a script, add an href="javascript:void(0)" to the links without hrefs:

<a class="link2" onclick="...">program</a>

would become:

<a href="javascript:void(0)" class="link2" onclick="...">program</a>

2. Change the style definition of link2 from:

a.link2 {text-decoration: none; color:white}
a.link2:hover {text-decoration: none; color:black}
a.link2:visited {text-decoration: none; color:white}

to:

.link2 {text-decoration: none; color:white}
a.link2:hover {text-decoration: none; color:black}
.link2:visited {text-decoration: none; color:white}

For some reason, IE refuses to handle the hover correctly if the anchor ref is added to .link2 { and to .link2:visited

In addition, I noticed these things that didn't affect the document as far as I could tell, but might cause problems in some browsers:

1. You have some bad formatting in the html (a style tag begins inside a div and ends outside. An extra </head> tag and an extra set of title tags are located toward the bottom of the document.

2. Your css uses color names sometimes instead of hex, which is technically not valid css and might cause some problems.

Hope this helps,

ajkimoto

Bernard Marx

8:41 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well spotted with the href, ajkimoto.
The <A> tag needs an href to be considered a 'link', and thus will work with those pseudo classes in IE.

I think I know the cause of the slight problems reported in your last post.
It's all to do with order.

Pseudo classes, to work as expected, should be declared:

link
visited
hover
active

There was some article on it somewhere. They came up with a mnemonic that started:
"Love V..."
Can't find it. Oh well.

( or was that: L,V,A,H ?)

ajkimoto

9:40 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



Bernard Marx,

That is so cool. I will have to permanently impress that upon a neuron or two.

BTW, was this the thread for which you were searching?

[webmasterworld.com...]

ajkimoto

Bernard Marx

9:49 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, no it wasn't, but it'll certainly do!

jonwald

12:26 am on Apr 29, 2005 (gmt 0)

10+ Year Member



I FINALLY got it to work, thanks to you two. Your suggestions were all right on - though I could only make it work with the "a" prefacing all the links. And oddly, I could also only make it work by adding a vlink tag in the body tag, otherwise there seemed to be some kind of overriding browser command that turned all my visited links purple.

Anyway, much appreciated.