Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Onclick and OnMouseOut

Status
Not open for further replies.

zapster

Programmer
Jun 8, 2001
36
GB
Hi all

I have a link which opens up a new window, which works fine :) What I need to do is when the user clicks on the link, change the colour of the text and then return it back to the previous style. The link also need to change colour when the mouse moves over the link. (ie 3 colours)

Does any one know how I stop the link from staying the colour I have set it, once I have used the onclick command?

This is what I have so far :
Code:
<a class='jumphover' onClick='this.style.color=&quot;red&quot;;
window.open(&quot;/jsp/help.jsp?help=allo&quot;, &quot;help&quot;, &quot;width=500,height=600 scrollbars=yes,resizable=yes,location=no&quot;)'
onMouseOver=&quot;this.className='jumpover'&quot;
onMouseOut=&quot;this.className='jumphover'&quot; >< help ></a>
 
the css (style sheets) defintions can do that sort of thing for you. they mostly work in IE and sometimes in Netscape, i forget which ones netscape doesnt like. i think it is the mouse over (hover) that it doesnt like...

you'll have to look up some CSS documentation on the web to look for the definition for when you click a link, but if you put the following code in the <head> of your html, you will get red links that turn yellow when you put your mouse over them (at least in ie)

<style type=&quot;text/css&quot;>
<!--
a { color: #FF0000 }
a:hover { color: #FFFF00 }
-->
</style>
 
yeah, & a:visited, may be a:eek:ver.. regards, vic
 
The problem is window focus, once the page has focus again, the link will revert to the color you want. I don't know that I'd want to do this, but here's how you could try...

Code:
function changeColor() {	  
   self.focus();
   setTimeout('window.open(&quot;nextpage.html&quot;);', 2000);	
}


Just use the above function to open your new window, it briefly (2 seconds, 2000 milliseconds) gives the focus back before it opens the new window.

-Scott
 
Thanks guys

Theres now been a re-think on the problem. :-(
What I need to now do is change the linking text colour, ie onclick function and open up a new window with the relative url. But when the new window is closed I have to change the parent windows text link back to the orginal colour.

Any ideas how I can do this ?

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top