Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,156,453 members, 7,830,239 topics. Date: Thursday, 16 May 2024 at 06:27 PM

Help Me With This Javascript Snippet - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help Me With This Javascript Snippet (723 Views)

Were Can I Download Free Video Tutorials On Javascript Or Ruby / Javascript With NodeJS / I Need Help With This Vb Snippet. (2) (3) (4)

(1) (Reply)

Help Me With This Javascript Snippet by tundebabzy: 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: 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)

.net Question Guys / When Shall I Meet Good Programmers In Naija? / Intranet Configurations On Internet information server(IIS)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.