Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    454

    Unanswered: Is there a way to detect the client window's width?

    I need to know the width of the client window and then I can pick the background file to show. Thanks in advance.

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    I found the way to get the width of the client's screen using JavaScript screen.availWidth. But when I put the following code in my page

    <head>
    <title>My Page</title>
    <SCRIPT language="JavaScript1.2">
    <!--
    <% Dim backgroundFile %>
    function loadBackgroundFile() {
    var sw = screen.availWidth;
    if (sw <= 800) {
    <% backgroundFile = "../images/background1.jpg" %>;
    }
    else {
    <% backgroundFile = "../images/background2.jpg" %>;
    }
    }
    //-->
    </SCRIPT>
    </head>

    <body bgcolor="#808080" bottommargin="3" leftmargin="3" rightmargin="3" topmargin="3" onload="loadBackgroundFile();">

    it always shows background2.jpg even when the width is changed to 1024. Does someone give a help? Thanks.

Posting Permissions

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