471,338 Members | 944 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Window size via Javascript for Safari (Mac)

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.
Jul 23 '05 #1
6 2876
Giuseppe Chielli wrote:
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>
--
Rob
Jul 23 '05 #2
Giuseppe Chielli <gi******@NOSPAMlibero.it> wrote:
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?


window.innerWidth and window.innerHeight work on Safari (just tested myself).

--
Jeremy | je****@exit109.com
Jul 23 '05 #3
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.

Jul 23 '05 #4
Giuseppe Chielli wrote:
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.


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

Jul 23 '05 #5
Giuseppe Chielli <gi******@NOSPAMlibero.it> wrote:
Jeremy Nixon ha scritto:
window.innerWidth and window.innerHeight work on Safari (just tested myself).
Which version of Safari? And which operating system?


1.2.4 on 10.3.8.
Have you ever tested if it works with frames too?


No, but I've heard that it has a bug there, so that may be the cause of
the problem.

--
Jeremy | je****@exit109.com
Jul 23 '05 #6
RobB wrote:
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?

Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Anna Quick | last post: by
2 posts views Thread by MM | last post: by
29 posts views Thread by wayne | last post: by
2 posts views Thread by laredotornado | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.