By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,571 Members | 3,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,571 IT Pros & Developers. It's quick & easy.

Window size via Javascript for Safari (Mac)

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.