Akasha Posted February 3, 2007 Share Posted February 3, 2007 HelloI found some code and used it for my website, and it works fine with IE but when i use it in Mozilla it doesn't work.I am a beginner with javascript so i doe not really know how ik can fix this or if its even fixableThe code shows a text when i rollover a link.This is the part in the head of the page <script LANGUAGE="JavaScript"> var t var x = 450, y = 650 var txt = 0 document.write("<div id='text1' style='position:absolute;top:-80px;left:100px;width:400px;height:20px'><font size=+2 color='#CCCCCC'>Muziek</font></div>") document.write("<div id='text2' style='position:absolute;top:-80px;left:100px;width:400px;height:20px'><font size=+2 color='#CCCCCC'>Fotoos</font></div>") document.write("<div id='text3' style='position:absolute;top:-80px;left:100px;width:400px;height:20px'><font size=+2 color='#CCCCCC'>Video</font></div>") </script> <script LANGUAGE="JavaScript"> function showtip(txt) { t=txt show() } function outtip(t) { clearTimeout(s) document.all["text"+t].style.pixelTop = -50 } function show() { document.all["text"+t].style.pixelTop = x document.all["text"+t].style.pixelLeft = ys=setTimeout("show()",10) } </script> and this i sthe part in the body of the page <a href="music.asp" onMouseover="showtip('1')" onMouseout="outtip('1')" target="_self"><img src="Images/music_icon.gif" border="0"></a><a href="galleries.asp" onMouseover="showtip('2')" onMouseout="outtip('2')" target="_self"><img src="Images/photo_icon.gif" border="0"></a><a href="videos.asp" onMouseover="showtip('3')" onMouseout="outtip('3')" target="_self"><img src="Images/video_icon.gif" border="0"></a> how can i make it work in IE as wel in mozillathnx in advance Link to comment Share on other sites More sharing options...
Chocolate570 Posted February 4, 2007 Share Posted February 4, 2007 It's because you're using document.all. Document.all doesn't work in any browser besides Internet Explorer. Link to comment Share on other sites More sharing options...
Akasha Posted February 5, 2007 Author Share Posted February 5, 2007 well, what do you use in mozilla then??? Link to comment Share on other sites More sharing options...
jesh Posted February 5, 2007 Share Posted February 5, 2007 well, what do you use in mozilla then??? document.getElementById() Link to comment Share on other sites More sharing options...
Akasha Posted February 6, 2007 Author Share Posted February 6, 2007 Ok thnx so i have created this, but still not working function showtip(txt) { t=txt show() } function outtip(t) { clearTimeout(s)if (document.all) {document.all["text"+t].style.pixelTop = -50;}if (document.GetElementById) {document.GetElementById("text"+t).style.Top = -50;}}function show() { if (document.all) {document.all["text"+t].style.pixelTop = x;document.all["text"+t].style.pixelLeft = y;}if (document.GetElementById) {document.GetElementById("text"+t).style.Top = x;document.GetElementById("text"+t).style.Left = y;}s = setTimeout("show()",10) }</script> Link to comment Share on other sites More sharing options...
jesh Posted February 6, 2007 Share Posted February 6, 2007 You were close! It's document.getElementById rather than document.GetElementById. Link to comment Share on other sites More sharing options...
Akasha Posted February 7, 2007 Author Share Posted February 7, 2007 hmzz.... still not working Link to comment Share on other sites More sharing options...
jesh Posted February 7, 2007 Share Posted February 7, 2007 Rather than this: document.GetElementById("text"+t).style.Top = -50; Try this: document.getElementById("text"+t).style.top = -50 + "px"; Link to comment Share on other sites More sharing options...
Akasha Posted February 7, 2007 Author Share Posted February 7, 2007 Cool thnxonly problem now is.it doesn't disappear anymore Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now