javascript alert problem

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

    javascript alert problem

    <script language="JavaS cript">
    !--
    function onLoad()
    {
    if( self.innerWidth < 1024 )
    {
    self.moveTo( 0, 0 );
    self.resizeTo( screen.availWid th, screen.availHei ght );
    }

    if( self.innerWidth < 1024 )
    {
    alert( "This Web page was designed to be viewed using a" + " screen
    resolution of 1024x768 or larger." );
    }
    }

    Why thus code is not working when my screen resolution is 800*600? Please
    Help!!

    --
    Thanks and Regards

    Jorn


  • Evertjan.

    #2
    Re: javascript alert problem

    Jorntk wrote on 04 mei 2004 in comp.lang.javas cript:
    [color=blue]
    > <script language="JavaS cript">
    > !--
    > function onLoad()
    > {
    > if( self.innerWidth < 1024 )
    > {
    > self.moveTo( 0, 0 );
    > self.resizeTo( screen.availWid th, screen.availHei ght );
    > }
    >
    > if( self.innerWidth < 1024 )
    > {
    > alert( "This Web page was designed to be viewed using a" + " screen
    > resolution of 1024x768 or larger." );
    > }
    >}
    >[/color]

    dit you try this [oonly this code in a html-file:

    <body onload="alert(s elf.innerWidth) ">

    ??

    undefined

    =============== ===

    Now try:

    <body onload="alert(s creen.availWidt h)">

    See:
    <http://msdn.microsoft.com/workshop/
    author/dhtml/reference/dhtml_reference _entry.asp>

    and perhaps also:
    <http://msdn.microsoft. com/workshop/author/om/measuring.asp>

    because client users more often than not do not want full screen

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Jorntk

      #3
      Re: javascript alert problem

      Ok, it work now. But i got new problem.
      I put the alert in a header.php where i will call the header.php everytime.
      This cause the alert pop up when I click every button to view new page.
      So, is there anyway to limit the alert to only pop up for one time??
      Please advice. Thanx!


      Comment

      • Ivo

        #4
        Re: javascript alert problem

        "Jorntk" wrote[color=blue]
        > Ok, it work now. But i got new problem.
        > I put the alert in a header.php where i will call the header.php[/color]
        everytime.[color=blue]
        > This cause the alert pop up when I click every button to view new page.
        > So, is there anyway to limit the alert to only pop up for one time??
        > Please advice. Thanx![/color]

        The usual way to do this is with a cookie or something serverside like a
        session variable. There is no other way of knowing the difference between
        first time visitors and those going to the next page.
        But also to be considered: There might be a lot people going to the next
        page if you leave it up to them to resize their window. And unless you have
        something very special to show, you should not design for any specific
        screen resolution at all. Most users do not even know how to change their
        resolution (assuming, against better judgement, they would be willing to go
        through of trouble of doing so only to see your site) so the javascript will
        do nothing but annoy people.
        HTH
        Ivo


        Comment

        • Michael Winter

          #5
          Re: javascript alert problem

          On Tue, 4 May 2004 19:13:33 -0700, Jorntk <jorntk@yahoo.c om> wrote:
          [color=blue]
          > Ok, it work now. But i got new problem.
          > I put the alert in a header.php where i will call the header.php
          > everytime.
          > This cause the alert pop up when I click every button to view new page.
          > So, is there anyway to limit the alert to only pop up for one time??
          > Please advice. Thanx![/color]

          Frankly, you shouldn't do it at any time. The users don't know or care
          what it was designed for. After all, their resolution will, more than
          likely, be set to the optimal value anyway, so what good will it do? Sites
          for the World Wide Web should use liquid design so it doesn't matter
          (within reason) what the resolution is, large or small. Finally, screen
          resolution means practially nothing. It's set to 1024x768 on this machine,
          but you'll only get 866x582 to work with once you remove toolbars,
          sidebars, and the like.

          One final point, you do realise that statistics (unreliable as they are)
          show the majority of users use 800x600, don't you?

          Mike

          --
          Michael Winter
          M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

          Comment

          • kaeli

            #6
            Re: javascript alert problem

            In article <40974c4c_1@new s.tm.net.my>, jorntk@yahoo.co m enlightened us
            with...[color=blue]
            > <script language="JavaS cript">
            > !--
            > function onLoad()
            > {
            > if( self.innerWidth < 1024 )
            > {
            > self.moveTo( 0, 0 );
            > self.resizeTo( screen.availWid th, screen.availHei ght );[/color]

            Um, you do know that us Opera and Mozilla users can disable that
            nonsense, right?
            You have no right to resize or move MY windows. Sorry.
            [color=blue]
            > }
            >
            > if( self.innerWidth < 1024 )
            > {
            > alert( "This Web page was designed to be viewed using a" + " screen
            > resolution of 1024x768 or larger." );[/color]

            I guess I won't be using your page. Neither will most people. The
            majority of users use 800 by 600. And an alert? How annoying. I can
            read. If you want to tell people that you can't code, just put it on the
            page.

            Gee, I sure hope disabled people don't need your site, either.

            --
            --
            ~kaeli~
            A hangover is the wrath of grapes.



            Comment

            • Grant Wagner

              #7
              Re: javascript alert problem

              Jorntk wrote:
              [color=blue]
              > Ok, it work now. But i got new problem.
              > I put the alert in a header.php where i will call the header.php everytime.
              > This cause the alert pop up when I click every button to view new page.
              > So, is there anyway to limit the alert to only pop up for one time??
              > Please advice. Thanx![/color]

              You only think you have it working. For starters, "self.innerWidt h" returns
              "undefined" on Internet Explorer, which is always less then 1024 on Internet
              Explorer.

              On browsers like Gecko based browsers (Netscape 7.1, Mozilla, Firefox, Camino,
              Opera 7.23), where self.innerWidth actually returns typeof "number", even a
              user with a 1024 x 768 desktop will be told they aren't running their browser
              at 1024 x 768, because window.innerWid th is ALWAYS less then the width of the
              applicable desktop (due to borders and scrollbars and any side-docked
              toolbars).

              Not to mention that in Netscape 7.1, Mozilla and Firefox, browsers where you
              are actually able to retrieve self.innerWidth (and make an incorrect assumption
              about the size of their browser based on that value), users can disable the
              ability for you to move or resize their browser.

              --
              | Grant Wagner <gwagner@agrico reunited.com>

              * Client-side Javascript and Netscape 4 DOM Reference available at:
              *


              * Internet Explorer DOM Reference available at:
              *


              * Netscape 6/7 DOM Reference available at:
              * http://www.mozilla.org/docs/dom/domref/
              * Tips for upgrading JavaScript for Netscape 7 / Mozilla
              * http://www.mozilla.org/docs/web-deve...upgrade_2.html


              Comment

              Working...