Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:20:38+00:00 2026-06-08T05:20:38+00:00

How can I get the exact height and width of the currently open browser

  • 0

How can I get the exact height and width of the currently open browser screen window?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:20:40+00:00Added an answer on June 8, 2026 at 5:20 am

    You can use Javascript to get the viewport width and height. Then pass the values back via a hidden form input or ajax.

    At its simplest

    var width = $(window).width();
    var height = $(window).height();
    

    Complete method using hidden form inputs

    Assuming you have: JQuery framework.

    First, add these hidden form inputs to store the width and height until postback.

    <asp:HiddenField ID="width" runat="server" />
    <asp:HiddenField ID="height" runat="server" />
    

    Next we want to get the window (viewport) width and height. JQuery has two methods for this, aptly named width() and height().

    Add the following code to your .aspx file within the head element.

    <script type="text/javascript">
    $(document).ready(function() {
    
        $("#width").val() = $(window).width();
        $("#height").val() = $(window).height();    
    
    });
    </script>
    

    Result

    This will result in the width and height of the browser window being available on postback. Just access the hidden form inputs like this:

    var TheBrowserWidth = width.Value;
    var TheBrowserHeight = height.Value;
    

    This method provides the height and width upon postback, but not on the intial page load.

    Note on UpdatePanels: If you are posting back via UpdatePanels, I believe the hidden inputs need to be within the UpdatePanel.

    Alternatively you can post back the values via an ajax call. This is useful if you want to react to window resizing.

    Update for jquery 3.1.1

    I had to change the JavaScript to:

    $("#width").val($(window).width());
    $("#height").val($(window).height());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can we get exact time to load a page using Selenium WebDriver? We
From what I know, you can't get the exact number of users which downloaded
I have a UIImageView in a UITableView Header. How can I get the exact
I am trying to have this exact JSON syntax but can't get to it:
For a particular Image say on blue background, I can get its Width and
How can i get the exact time taken by lucene to search a string.
Can get all triples with value null in specific field? All people with date_of_birth
We can get class Class object by 3 methods: MyClass.class obj.getClass Class.forName(className) I don't
I can get the file path with: (message (file-name-directory (or buffer-file-name load-file-name))) But if
I can get this to work: [<DllImport(user32.dll)>] extern bool GetClientRect(nativeint, RECT*) let getClientRect hwnd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.