How to set the size of a popup window

Joseph Lestingi 0 Reputation points
2023-07-16T14:30:26.3266667+00:00

Good morning,

I am trying to set the size of a popup window. It appears that all of the popup windows open up to the same size regardless of the actual size that is to be displayed.

Joe

Windows for business | Windows Client for IT Pros | User experience | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2023-07-17T13:32:56.5033333+00:00

    Hello there,

    To set the size of a popup window in JavaScript, you can use the window.open() method and specify the desired width and height as parameters. Here's an example:

    javascript

    Copy code

    // Open a popup window with specified width and height

    var width = 500; // Set the desired width in pixels

    var height = 300; // Set the desired height in pixels

    var popupWindow = window.open("", "_blank", "width=" + width + ", height=" + height);

    In this example, window.open() is called with three parameters:

    The first parameter ("") specifies the URL or about:blank if you want to open an empty window.

    The second parameter ("_blank") specifies the target attribute to open the window in a new tab or window.

    The third parameter ("width=" + width + ", height=" + height) specifies the window features, including the width and height.

    You can adjust the width and height variables according to your desired dimensions in pixels.

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.