Window size via Javascript for Safari (Mac)

G

Giuseppe Chielli

Hi! I'm new to this newsgroup. I have a problem: I need to get the
window size via Javascript; I usually use window.innerWidth or
document.body.clientWidth with IE and Firefox and it properly works, but
it doesn't work with Safari. It returns null or undefined...
How can I get the window size on Safari?

Thanks a lot to everyone.
 
R

RobG

Giuseppe said:
Hi! I'm new to this newsgroup. I have a problem: I need to get the
window size via Javascript; I usually use window.innerWidth or
document.body.clientWidth with IE and Firefox and it properly works, but
it doesn't work with Safari. It returns null or undefined...
How can I get the window size on Safari?

Thanks a lot to everyone.

Try self.innerHeight/Width. For more information, have a poke around
here:

<URL:http://www.quirksmode.org/viewport/compatibility.html>
 
G

Giuseppe Chielli

Jeremy Nixon ha scritto:
window.innerWidth and window.innerHeight work on Safari (just tested myself).

Which version of Safari? And which operating system? Have you ever
tested if it works with frames too?
Thanks a lot.
 
R

RobB

Giuseppe said:
Jeremy Nixon ha scritto:
tested myself).

Which version of Safari? And which operating system? Have you ever
tested if it works with frames too?
Thanks a lot.

Should have mentioned frames the first time around. There's an
oft-reported bug in v. 1.2 (possibly others) where
innerWidth/innerHeight report '0' respectively. The usual workaround
has been to load a dummy document in the frame/iframe first; after this
the problem seems to disappear. hth
 
G

Giuseppe Chielli

RobB said:
Should have mentioned frames the first time around.
Sorry...

There's anoft-reported bug in v. 1.2 (possibly others) where
innerWidth/innerHeight report '0' respectively. The usual workaround
has been to load a dummy document in the frame/iframe first; after this
the problem seems to disappear.

Dummy document? Like the following:

<HTML>

<HEAD>
<TITLE>Blank page</TITLE>
</HEAD>

<BODY>
</BODY>

</HTML>

I should load this document at first, then I should load my document.
Is it correct?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top