₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,134 members, 8,420,509 topics. Date: Thursday, 04 June 2026 at 10:47 PM

Toggle theme

Help Me With This Javascript Snippet - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp 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"wink
{
var changeNow=document.getElementById("biglink1"wink;
changeNow.style.backgroundColor = "FFFF99";
}
if(window.event.type=="mouseout"wink
{
var changeNow=document.getElementById("biglink1"wink;
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"wink
{
if(window.event.type="mouseover"wink
{

var changeNow = document.getElementById("biglink1"wink;
changeNow.style.backgroundColor = "#FFFF99";
}
if(window.event.type="mouseout"wink
{
var changeNow = document.getElementById("biglink1"wink;
changeNow.style.backgroundColor = "#FFFFFF";
}
}
else
{
if(evt.type=="mouseover"wink
{
var changeNow=document.getElementById("biglink1"wink;
changeNow.style.backgroundColor = "#FFFF99";
}
if(evt.type=="mouseout"wink
{
var changeNow=document.getElementById("biglink1"wink;
changeNow.style.backgroundColor = "#FFFFFF";
}
}
}
Thanks again
1 Reply

Were Can I Download Free Video Tutorials On Javascript Or RubyJavascript With NodeJSI Need Help With This Vb Snippet.234

Building Large Scale Apps With Backbone.jsNeed Help With Service That Can Process Text MessagesHow Feasible Is The Idea Of Driving A Car With A Computer Controlled Program