Wednesday, 23 May 2007

Java script not working in Firefox while works in IE

Hi Friends,
I was using followig java script function to get rollover effects for the images. I am using ASP.NET. Master page and child page and IIS.
This function was working excellent in Internet Explorer (I.E) (but was not working int the Firefox browser.
i was using this function onmouseover and onmouseout events.

where img_name=name of the image source control
and img_src=name of the image to show.


function movepic(img_name,img_src) {
document.forms[0].elements[img_name].src=img_src;
}

I found solution:

If we change the above function as follow it works with both Firefox and I.E
function movepic(img_name,img_src) {
document.getElementById(img_name).src=img_src;


}






No comments: