Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


swapping two images with fade effects not working in IE



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
sundarraj_mca



Joined: 14 May 2008
Posts: 19

PostPosted: Fri Jul 04, 2008 10:26 am    Post subject: swapping two images with fade effects not working in IE Reply with quote

javascript:

window.onload = function()

{
opacity('container', 49, 50, 100, 'images/2.jpg');
opacity('container1', 49, 50, 100, 'images/1.jpg');
}

function swap(opacity, id,img_src)
{
document[id].src=img_src;
}

function opacity(id, opacStart, opacEnd, millisec, img_src) {
//speed for each frame
var speed = Math.round(millisec / 100);
var timer = 0;

//determine the direction for the blending, if start and end are the same nothing happens
if(opacStart > opacEnd) {
for(i = opacStart; i >= opacEnd; i--) {
setTimeout("changeOpac(" + i + ",'" + id + "','" + img_src + "')",(timer * speed));
timer++;
}
} else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++)
{
setTimeout("changeOpac(" + i + ",'" + id + "','" + img_src + "')",(timer * speed));
timer++;
}
}
}

//change the opacity for different browsers
function changeOpac(opacity, id, img_src) {
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
swap(opacity, id, img_src);
}

html:

<body>
<img id="container" src="images/2.jpg" width="100" height="100" border="0" onmouseover="opacity('container', 50, 100, 500, 'images/1.jpg');" onmouseout="opacity('container', 100, 50, 500, 'images/2.jpg');" style="cursor:pointer;" />
<img id="container1" src="images/1.jpg" width="100" height="100" border="0" onmouseover="opacity('container1', 50, 100, 500, 'images/2.jpg');" onmouseout="opacity('container1', 100, 50, 500, 'images/1.jpg');" style="cursor:pointer;" />
</body>


it works in opera but not working in IE
Back to top
View user's profile Send private message Send e-mail
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 629
Location: Cebu City Philippines

PostPosted: Fri Jul 04, 2008 2:23 pm    Post subject: Re: swapping two images with fade effects not working in IE Reply with quote

See if changing this part:
Code:

document[id].src=img_src;


to:
Code:

document.getElementById(id).src=img_src;


proves an aide Wink
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap