Help Me With This Javascript Snippet - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help Me With This Javascript Snippet (866 Views)
1 Reply
| Help Me With This Javascript Snippet by tundebabzy(op): 8:48am On Apr 11, 2010 |
Hello, Please i need help so that I can achieve cross browser functionality with this java script snippet: function changeColor1() { if(window.event.type=="mouseover" ![]() { var changeNow=document.getElementById("biglink1" ;changeNow.style.backgroundColor = "FFFF99"; } if(window.event.type=="mouseout" ![]() { var changeNow=document.getElementById("biglink1" ;changeNow.style.backgroundColor = "white"; } } The code is to change the background color of a div when mouseover is fired and back to white when mouseout is fired. However, this code works only for IE. Can anyone help convert this to a crossbrowser code. |
| Re: Help Me With This Javascript Snippet by dellnet: 4:16pm On Apr 11, 2010 |
two examples. one in the tag and the other in a function. all should work across browsers. <div id="biglink1" onmousemove="this.style.backgroundColor='FFFF99'" onmouseout="testfunction(this)" style="position:absolute;">blah blah blah</div> <script type=""> function testfunction(Obj) { Obj.style.backgroundColor = 'FFFFFF'; } </script> |
| Re: Help Me With This Javascript Snippet by tundebabzy(op): 9:40pm On Apr 12, 2010 |
Thanks. I was able to achieve the effect with this code. The first if will work if the browser. The other branch is for other browsers function changeColor1(evt) { if(typeof evt == "undefined" ![]() { if(window.event.type="mouseover" ![]() { var changeNow = document.getElementById("biglink1" ;changeNow.style.backgroundColor = "#FFFF99"; } if(window.event.type="mouseout" ![]() { var changeNow = document.getElementById("biglink1" ;changeNow.style.backgroundColor = "#FFFFFF"; } } else { if(evt.type=="mouseover" ![]() { var changeNow=document.getElementById("biglink1" ;changeNow.style.backgroundColor = "#FFFF99"; } if(evt.type=="mouseout" ![]() { var changeNow=document.getElementById("biglink1" ;changeNow.style.backgroundColor = "#FFFFFF"; } } } Thanks again |
Were Can I Download Free Video Tutorials On Javascript Or Ruby • Javascript With NodeJS • I Need Help With This Vb Snippet. • 2 • 3 • 4
Building Large Scale Apps With Backbone.js • Need Help With Service That Can Process Text Messages • How Feasible Is The Idea Of Driving A Car With A Computer Controlled Program
