₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,389 members, 8,511,601 topics. Date: Monday, 02 November 2026 at 03:01 AM

Toggle theme

Help Me With This Javascript Snippet - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Help Me With This Javascript Snippet (880 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 Ruby • Javascript With NodeJS • I Need Help With This Vb Snippet. • 2 • 3 • 4

I Need Help Pls On My Php Script • My Games • How Feasible Is The Idea Of Driving A Car With A Computer Controlled Program