Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Question??? Need Help

    I have a script that I need to finish. I want to use JavaScript to detect a users screen resolution then post it back to the server so I can get it in ASP.

    This is what I have:
    <HTML>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function resolution() {
    colors = window.screen.colorDepth;
    document.form.colordepth.value = window.screen.colorDepth;
    document.form.width.value = window.screen.width;
    document.form.height.value = window.screen.height;
    }
    //--></script>
    </head>
    <body OnLoad="resolution()">
    <form action="nistemp.asp" name=form>
    <input type=text name=width value="width.value">
    <input type=text name=height>
    <input type=text name=colordepth>
    <input type=text name=i value="<%=nis%>">
    </form>
    <script type='text/javascript'>document.form.submit();</script>
    </body>
    </HTML>

    Now Without the document.form.submit I see the values in the forms but They dont go to the server when I submit because I have no value set for each form.

    Problem:
    How do I achieve this:
    <input type=text name=height value="JS Variable???????">

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now Without the document.form.submit I see the values in the forms but They dont go to the server when I submit because I have no value set for each form.
    It's not apparent why you need a form to do this? What are you doing with the values in ASP?

    How do I achieve this:
    <input type=text name=height value="JS Variable???????">
    var colors = window.screen.colorDepth;
    etc.


    -james
    Last edited by jamescover; 08-23-2004 at 05:50 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #3
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Code:
    <html>
    <head>
    <script type='text/javascript'>
    function resolution() {
      self.location.href = 'nistemp.asp?width=' + window.screen.width + '&height=' + window.screen.height + '&colordepth=' + window.screen.colorDepth + '&i=<%=nis%>';
    }
    window.onload = resolution;
    </script>
    </head>
    <body>
    </body>
    </html>
    dumpfi


  •  

    Posting Permissions

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