Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to detect screen resolution?

Hi,

How can I detect screen resolution and pass the value to a ASP variable?


thanks!

Comments

  • ManningManning Posts: 1,621Member
    : Hi,
    :
    : How can I detect screen resolution and pass the value to a ASP variable?

    If the user has javascript enabled you can detect it (method varies by browser, but you can look it up on google), and then submit the values to an ASP page by redirecting with them in the querystring.
  • ssvasanssvasan Posts: 101Member
    : : Hi,
    : :
    : : How can I detect screen resolution and pass the value to a ASP variable?
    :
    : If the user has javascript enabled you can detect it (method varies by browser, but you can look it up on google), and then submit the values to an ASP page by redirecting with them in the querystring.
    :

    Use the VBScript Screen Object as show below : -





    Using Screen Object


    document.write ""
    document.write "
    Screen Width " & screen.width
    document.write "
    Screen Height " & screen.height
    document.write "
    "




  • ManningManning Posts: 1,621Member
    : : : Hi,
    : : :
    : : : How can I detect screen resolution and pass the value to a ASP variable?
    : :
    : : If the user has javascript enabled you can detect it (method varies by browser, but you can look it up on google), and then submit the values to an ASP page by redirecting with them in the querystring.
    : :
    :
    : Use the VBScript Screen Object as show below : -
    :
    :
    :
    :
    :
    :
    :
    :

    Using Screen Object

    :
    :
    : document.write ""
    : document.write "
    Screen Width " & screen.width
    : document.write "
    Screen Height " & screen.height
    : document.write "
    "
    :
    :
    :

    That's client side VBScript, not ASP, which is only supported by IE. That limits the number of users that code will work for (although IE does make up like 90% of the market, so it doesn't limit it that much...)
  • lillulillu Posts: 308Member
    As I pointed out earlier, ASP does not see the browser or any of it's properties (screen, frames etc). It just sends an HTML stream to the browser via HTTP.
    It may be possible to use a component in ASP but I've never seen one doing this. The solution is to use javascript (cross-browser code if possible) then store screen values in a cookie. Then read the values from the cookie.






    <%
    'Declare variables
    Dim strScreenWidth
    Dim strScreenHeight

    'Read the cookies with the width and height
    strScreenWidth = Request.Cookies("ScreenWidth")
    strScreenHeight = Request.Cookies("ScreenHeight")

    'If not cookie was made then say the screen size is 800x600
    If strScreenWidth = "" Then strScreenWidth = 800
    If strScreenHeight = "" Then strScreenHeight = 600
    %>

    <%
    Response.Write("Your screen width is: " & strScreenWidth & "<br>")
    Response.Write("Your screen height is: " & strScreenHeight)
    %>


    : : : : Hi,
    : : : :
    : : : : How can I detect screen resolution and pass the value to a ASP variable?
    : : :
    : : : If the user has javascript enabled you can detect it (method varies by browser, but you can look it up on google), and then submit the values to an ASP page by redirecting with them in the querystring.
    : : :
    : :
    : : Use the VBScript Screen Object as show below : -
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    : :

    Using Screen Object

    : :
    : :
    : : document.write ""
    : : document.write "
    Screen Width " & screen.width
    : : document.write "
    Screen Height " & screen.height
    : : document.write "
    "
    : :
    : :
    : :
    :
    : That's client side VBScript, not ASP, which is only supported by IE. That limits the number of users that code will work for (although IE does make up like 90% of the market, so it doesn't limit it that much...)
    :

    [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)

Sign In or Register to comment.