473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 3016
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Anna Quick | last post by:
I am quite new to javascript, and don't seem to find the problem with stupid internet explorer. The script works fine in safari and mozilla. I searched the groups, but evidently put in the wrong...
4
by: J Fisk | last post by:
Hi, I've been banging my head on the wall over this for about two days now so any thoughts are much appreciated. I have a static .svg file with embedded onclick="open()"'s all over. The svg...
2
by: MM | last post by:
I am using the following code to display an image in a seperate window. <form> <input type=button onClick='window.open("image1.jpg","","width=260,height=260,resizable=0,border=0")' value=Shhow...
29
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
2
by: laredotornado | last post by:
Hi, Is it possible to fool Javascript running on a Mac Safari web browser into believing it is a PC IE browser? We have the following JS code that is detecting both Mac and Safari. Sadly, we do...
3
by: alison | last post by:
I am trying to redirect the parent page when the user clicks an html button in an aspx page by using the javascript: window.opener.location.href="EditOrders.aspx"; This works fine on IE for...
9
by: Ja NE | last post by:
(I'm not a programer, I have learned enough php to build my cms, but that doesn't make me coding guru, so please excuse me if I'm asking something trivail...) well, I have one upload form where...
7
by: petermichaux | last post by:
Hi, I have tried the following based on suggestions of the best way to insert JavaScript into a page. This is instead of using eval(). Unfortunately IE says "unexpected call to property or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.