473,378 Members | 1,415 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,378 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 3008
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.