Results 1 to 4 of 4

Thread: Help With Screen Resolution Detection

  1. #1
    Join Date
    Dec 2005
    Location
    Dallas Texas
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help With Screen Resolution Detection

    Hello,

    I would like to use the java script code below on my splash screen for screen resolution detection.

    But what I would like for it to do is give an "alert notice". Like the one used in
    the code for "NO right mouse button". Could someone tell me , or show me how this is done?

    Thanks,

    Rick



    <script language="JavaScript1.2">
    <!--

    /*
    Screen resolution detection and notification Script-
    © Dynamic Drive (www.dynamicdrive.com)
    For full source code, installation instructions,
    100's more DHTML scripts, and Terms Of
    Use, visit dynamicdrive.com
    */

    var correctwidth=1024
    var correctheight=768
    if (screen.width!=correctwidth||screen.height!=correctheight)
    document.write("This webpage is bested viewed with screen resolution "+correctwidth+"*"+correctheight+". Your current resolution is "+screen.width+"*"+screen.height+". If possible, please change the resolution!")
    //-->
    </script>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    When simply providing information, the document.write() method can always be replaced by the alert() method, though not always the other way around. So, assuming this is a valid DD script that works as written (looks to be), you can just switch from document.write to alert:

    Code:
    <script type="text/javascript">
    
    /*
    Screen resolution detection and notification Script-
    &#169; Dynamic Drive (www.dynamicdrive.com)
    For full source code, installation instructions,
    100's more DHTML scripts, and Terms Of
    Use, visit dynamicdrive.com
    */
    
    var correctwidth=1024
    var correctheight=768
    if (screen.width!=correctwidth||screen.height!=correctheight)
    alert("This webpage is best viewed with screen resolution "+correctwidth+"*"+correctheight+". Your current resolution is "+screen.width+"*"+screen.height+". If possible, please change the resolution!")
    
    </script>
    Notes: Extraneous 'hiding comments' removed. Opening script tag updated to current convention.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Dec 2005
    Location
    Moscow, Russia
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Or
    Code:
    <script>
    onload=function(){if (screen.width!=correctwidth||screen.height!=correctheight)
    document.getElementById('alert1').innerHTML=
    ("This webpage is best viewed with screen resolution "+correctwidth+"*"+correctheight+". Your current resolution is "+screen.width+"*"+screen.height+". If possible, please change the resolution!");}
    </script>
    <body>
    <div id=alert1></div> ...

  4. #4
    Join Date
    Dec 2005
    Location
    Dallas Texas
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    How simple, Thank you!

    Rick

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •