/    Sign up×
Community /Pin to ProfileBookmark

onclick() not working in FF

Hello all, i’ve got a gallery of thumbnails with an onclick event attached to them. when you click a thumbnail a larger image of that thumbnail pops up overtop all the thumbs which inturn have their opacity set to 10%…click the big image and it disappears and the thumbs return to 100%.

this works in IE (of course ? ) but not in FF. nothing happens when i click a thumbnail. below is the code for the big pic, the thumbs have the same onclick() code attached, only they send ‘block’ instead of ‘none’.

[CODE]
<div id=”big_pic_div”><img src=”just_bg.jpg” width=”334″ height=”203″ hspace=”2″ vspace=”2″ onclick=”big_pic(‘none’)” /><br />
Click Photo To Close</div>
[/CODE]

here is my javascript:

[CODE]
function big_pic(state){

dim = “alpha(opacity=10);” // for IE
undim = “alpha(opacity=100);” // for IE
moz_dim = “0.4”; // for MOZ
moz_undim = “1”; // for MOZ

if (state == “block”){

// ‘content’ is the div that contains the thumbs!

content.style.filter = dim; // sets thumb opacity to 10 – IE
content.style.MozOpacity= moz_dim; // sets thumb opacity to 10 – MOZ
big_pic_div.style.display = state; // sets display of larger pic
big_pic_div.style.filter = undim; // keeps nested big_pic_div from inheriting ‘content’ opacity – I THINK!
big_pic_div.style.MozOpacity = moz_undim; // MOZ version of above
} else {
content.style.filter = undim;
content.style.MozOpacity = moz_undim;
big_pic_div.style.display = state;
}
}
[/CODE]

thanks guys!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 20.2006 — You cannot reference an [b]id[/b]'d element as follows in other browsers (except, maybe, Opera -- which likes to act like IE):

big_pic_div.style.display

That should be more like this for cross-browser funcitonality:

document.getElementById("big_pic_div").style.display
Copy linkTweet thisAlerts:
@kreddauthorJun 20.2006 — duh ? goodness - always the simple things. thanks man.
Copy linkTweet thisAlerts:
@phpnoviceJun 20.2006 — You're welcome.

Cheers.
×

Success!

Help @kredd 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...