Flash Games

 FAQ   Search   Members   Groups   User Control Panel      Login 

It is currently Thu Jan 08, 2009 3:15 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: swapping two images with fade effects not working in IE
PostPosted: Fri Jul 04, 2008 10:26 am 
Offline

Joined: Wed May 14, 2008 6:06 am
Posts: 19
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 04, 2008 2:23 pm 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 778
Location: Cebu City Philippines
See if changing this part:
Code:
document[id].src=img_src;


to:
Code:
document.getElementById(id).src=img_src;


proves an aide ;)

_________________
Please don't PM me, let's keep the discussion on the public board.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review

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: