Window size via Javascript for Safari (Mac)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Giuseppe Chielli

    #1

    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.innerWid th or
    document.body.c lientWidth 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

    #2
    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.innerWid th or
    > document.body.c lientWidth 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.innerHeigh t/Width. For more information, have a poke around
    here:

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


    --
    Rob

    Comment

    • Jeremy Nixon

      #3
      Re: Window size via Javascript for Safari (Mac)

      Giuseppe Chielli <giuchiel@NOSPA Mlibero.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.innerWid th or
      > document.body.c lientWidth 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.innerWid th and window.innerHei ght work on Safari (just tested myself).

      --
      Jeremy | jeremy@exit109. com

      Comment

      • Giuseppe Chielli

        #4
        Re: Window size via Javascript for Safari (Mac)

        Jeremy Nixon ha scritto:
        [color=blue]
        > window.innerWid th and window.innerHei ght 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.

        Comment

        • RobB

          #5
          Re: Window size via Javascript for Safari (Mac)

          Giuseppe Chielli wrote:[color=blue]
          > Jeremy Nixon ha scritto:
          >[color=green]
          > > window.innerWid th and window.innerHei ght 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

          Comment

          • Jeremy Nixon

            #6
            Re: Window size via Javascript for Safari (Mac)

            Giuseppe Chielli <giuchiel@NOSPA Mlibero.it> wrote:[color=blue]
            > Jeremy Nixon ha scritto:
            >[color=green]
            >> window.innerWid th and window.innerHei ght 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

            Comment

            • Giuseppe Chielli

              #7
              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?

              Comment

              Working...