/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Works in IE, but not FireFox. Why?

Hi guys!
I have the following code that tweaks a div’s location based on the screen with (so it shows up under the button whose onmouseover event calls it).

It works on IE but not on FireFox. Any way to fix this? Thanks!

-Duffy

onmouseover=”document.getElementById(‘Layer2’).style.left=((screen.width – 800)/2)+ 541 ; [other stuff that works] ; [other stuff that also works]”

(If you’re wondering about the numbers, 800 = main table width, 541 is the offset in pixels from the main table’s left side that I want it to be, less half the screen width (the /2) puts in right where I want it.

Anyone who can help has my eternal gratitude.

Cheers!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 10.2008 — onmouseover="document.getElementById('Layer2').style.left=((screen.width - 800)/2)+ 541 + 'px';
Copy linkTweet thisAlerts:
@HalfNote5authorJul 10.2008 — Thanks!!

However, I'm having a new oddity - if the screen is not maximized, the math doesn't work properly (which figures, as there's less leftover space on either side of the main table.

and thoughts on how to correct that? Sorry for the bother, but I don't usually play much with javascript.

Thanks!
Copy linkTweet thisAlerts:
@robthescotJul 10.2008 — I don't think you want to use screen.width, document.body.clientWidth will give you the width of their browser.
Copy linkTweet thisAlerts:
@HalfNote5authorJul 10.2008 — Looks like exactly what I needed. Thanks!

screen width was the monitor resolution width, not the active window's viewport width.

Works now. Thanks everyone!
×

Success!

Help @HalfNote5 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.18,
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,
)...