/    Sign up×
Community /Pin to ProfileBookmark

Script problem NEED HELP

I am not very good at javascript, and i was wondering if anyone could rewrite this script so that it will work in a Mozilla browser (from [url]www.mozilla.org[/url]). someone told me how to fix it, but i still didnt understand what they were talking about. ill show ya the message…


__________
>

is there any way to rewrite the script or the page so that it performs
> the same function in windows ie then?

I thought I had given sufficient pointers to do that in my comments…

As for opacity. the code will look very similar; you’ll need to set object.style.MozOpacity instead of setting object.filters.whatever (and probably condition that on the presence of document.all).

Boris


__________

I have the script at [url]http://www.windedhero.com/cgi-bin/fade.js.[/url]
the goal of this script is to make an object fade to 80% opacity when a mouse passes over it, and to return to 100% opacity after the mouse moves out. there is an active example at [url]http://www.windedhero.com/board/index.shtml,[/url] as it works in microsoft internet explorer, but it will not work in a Mozilla explorer. and in case you’re too lazy, i have attached fade.js as a text document to this post.

[upl-file uuid=d2c85e30-8c05-468a-9938-c4d6c2c9562a size=1kB]fade.txt[/upl-file]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Squirrel448authorJan 09.2003 — Is there even anybody here that knows how to do this?
Copy linkTweet thisAlerts:
@TheBearMayMar 09.2004 — I must have missed this over the holidays, but if you're still interested this script bounces and fades an image at the same time. Works on IE6 and FireBird.
[code=php]
var browseIE = navigator.appName;
if(browseIE == "Microsoft Internet Explorer") browseIE = true;
else browseIE = false;
var tempY = 0;
var tempX = 0;
var yDir=1;
var xDir=1;
var imgTimer;
var opFilt=100;
var fadeVal=1;
function bounceImage(imgName){
if (browseIE)
document.getElementById(imgName).style.filter="alpha(opacity="+opFilt+")";
else document.getElementById(imgName).style.MozOpacity=opFilt/100;
opFilt=opFilt-fadeVal;
if(opFilt <= 0 || opFilt >= 100) fadeVal=fadeVal*(-1);
document.getElementById(imgName).style.top = tempY;
document.getElementById(imgName).style.left = tempX;
tempY=tempY+(1*yDir);
tempX=tempX+(1*xDir);
if ((tempX + document.getElementById(imgName).offsetWidth) >
document.getElementById(imgName).offsetParent.offsetWidth || tempX <= 0)
xDir=xDir*(-1);
if ((tempY + document.getElementById(imgName).offsetHeight) >
document.getElementById(imgName).offsetParent.offsetHeight || tempY <= 0)
yDir=yDir*(-1);
if (imgTimer) clearTimeout(imgTimer);
imgTimer=setTimeout("bounceImage('"+imgName+"')",50);
}
...
<div id="divImg" style="position:absolute; top: 0px; left: 0px;">
<img src="yourImage.gif" title="yourImage" onclick="bounceImage('divImg');"/>
</div>
[/code]
×

Success!

Help @Squirrel448 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...