Mike Albutt

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromMike Albutt
ToMe
SubjectSafari issue in alertSize
Date9 January 2009 12:04
Hello Mark.

I found your site when I [searched] for 'measure window size' or similar and
the alertSize example does pretty much what I want. I used it in
[URL] and tested it in various browsers. My PC Safari
3.1.2 fails the first test, if( typeof( window.innerWidth ) == 'number' ) by
erratically passing and failing this test. If it failed this one, it failed
the next two and dropped out with myWidth = 0, the start condition. So I
made the third, last condition simply else, not else if, so Safari would get
something. However, it still intermittently gets 0.

Is this something I have to live with in Safari, or is there another way for
that browser? Maybe you tested with a different version.

Mike Albutt
FromMe
ToMike Albutt
SubjectRe: Safari issue in alertSize
Date10 January 2009 07:34
Mike,

> Safari 3.1.2 fails the first test
> if( typeof( window.innerWidth ) == 'number' )

Safari 3.1 and 3.2 reliably get this right here on Windows and Mac.
However, you are making the mistake of running it before the page has
loaded - something I mention on the tutorial page where you got the
script. Until it has loaded, there is a chance the browser will not have
prepared the properties, especially if - like Safari - it uses offscreen
buffering for the initial load. You should only run the script from an
onload handler, or a script that runs some time after that (such as an
event handler). Inside a frameset, you may want to wait until the entire
frameset has loaded, not just the individual page inside a frame. If it
still fails, I can only assume there is a problem with your Safari
install, though I have no idea what the cause might be.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromMike Albutt
ToMe
SubjectRe: Safari issue in alertSize
Date14 January 2009 12:06
Hello, thank you for your prompt reply.

I tried putting the only call to my alertSize equivalent in <body onload
...> and it made no difference to my Safari. I expect I will get it to work
in the end and meanwhile I can work on the application. I am embarrassed
that while I have got good results from JavaScript, I struggle with what I
think of as O level grade problems. I will try going through your complete
tutorial and see if that helps.

Thanks,

Mike Albutt
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.