Connecting Tech Pros Worldwide Forums | Help | Site Map

Window size via Javascript for Safari (Mac)

Giuseppe Chielli
Guest
 
Posts: n/a
#1: Jul 23 '05
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.

RobG
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Window size via Javascript for Safari (Mac)


Giuseppe Chielli wrote:[color=blue]
> 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.[/color]

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

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


--
Rob
Jeremy Nixon
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Window size via Javascript for Safari (Mac)


Giuseppe Chielli <giuchiel@NOSPAMlibero.it> wrote:
[color=blue]
> 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?[/color]

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

--
Jeremy | jeremy@exit109.com
Giuseppe Chielli
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Window size via Javascript for Safari (Mac)


Jeremy Nixon ha scritto:
[color=blue]
> window.innerWidth and window.innerHeight work on Safari (just tested myself).[/color]

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

RobB
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Window size via Javascript for Safari (Mac)


Giuseppe Chielli wrote:[color=blue]
> Jeremy Nixon ha scritto:
>[color=green]
> > window.innerWidth and window.innerHeight work on Safari (just[/color][/color]
tested myself).[color=blue]
>
> Which version of Safari? And which operating system? Have you ever
> tested if it works with frames too?
> Thanks a lot.[/color]

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

Jeremy Nixon
Guest
 
Posts: n/a
#6: Jul 23 '05

re: Window size via Javascript for Safari (Mac)


Giuseppe Chielli <giuchiel@NOSPAMlibero.it> wrote:[color=blue]
> Jeremy Nixon ha scritto:
>[color=green]
>> window.innerWidth and window.innerHeight work on Safari (just tested myself).[/color]
>
> Which version of Safari? And which operating system?[/color]

1.2.4 on 10.3.8.
[color=blue]
> Have you ever tested if it works with frames too?[/color]

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

--
Jeremy | jeremy@exit109.com
Giuseppe Chielli
Guest
 
Posts: n/a
#7: Jul 23 '05

re: Window size via Javascript for Safari (Mac)


RobB wrote:
[color=blue]
> Should have mentioned frames the first time around.[/color]

Sorry...
[color=blue]
> 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.[/color]

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?

Closed Thread


Similar JavaScript / Ajax / DHTML bytes