Results 1 to 2 of 2

Thread: Screen resolution and detection script edit - valid?

  1. #1
    Join Date
    Apr 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Screen resolution and detection script edit - valid?

    1) Script Title:
    Screen resolution and detection script
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamicindex9/info1.htm
    3) Describe problem:
    I'd just like to quickly ask if this is valid, and if it isn't, a version that would work:
    Code:
    <script language="JavaScript1.2">
    <!--
    
    /*
    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=640
    var correctheight=480
    if (screen.width<=correctwidth||screen.height<=correctheight)
    document.write("<table border='1' width='100&#37;' align='center'>")
    else
    document.write("<table border='1' width='75%' align='center'>")
    //-->
    </script>
    The result should be that if the screen resolution of a person is less or equal to 640x480 a start table tag should be written with a size 100%, if it isn't (eg 1024x768) then draw it 75%
    Last edited by rctxtreme; 01-11-2007 at 04:04 AM.

  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

    I don't think you meant valid. It isn't and neither was the script that you adapted it from. Validation has to do with following standards for HTML code in your hard coded HTML, here this is in the script tag. Both scripts use the language attribute. This has been deprecated in favor of the type attribute which is now required:

    HTML Code:
    <script type="text/javascript">
    You can make this change in full confidence.

    Now, what I think you meant is, will it work. It looks like it will. I'm not so sure it is a great idea though. Screen resolution does not necessarily have anything to do with the size of the browser window. Also, your markup should be able to adapt to different sized windows without resorting to javascript, unavailable or disabled in many browsers. Without javascript, in this case you would have no table.
    - John
    ________________________

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

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
  •