Preston
Preston

Reputation: 420

Javascript popup window (minimum) height

I am creating a simple popup window and the window height will not resize to 30 pixels. It always defaults to 100 pixels. This behavior appears in all browsers. Am I missing something?

var myWindow;

function openWindow(url)  
{
    var windowFeatures = "width=530,height=30,status,resizable=no,scrollbars=0";
    myWindow = window.open(url, "welcome", windowFeatures);
}

Here is my link

<a href='javascript:void(0)' onclick=openWindow('http://www.stackoverflow.com')> Open the window  </a>

Upvotes: 2

Views: 3038

Answers (3)

Preston
Preston

Reputation: 420

Ok after a bit of tinkering I forgot about using the resizeTo() method. Can't believe I did not think of this earlier. (Wasted 2 hours)

Upvotes: 1

Surreal Dreams
Surreal Dreams

Reputation: 26380

Most browsers set a minimum window size around 100px so malicious users don't go making tiny windows from which to do lousy things. Even a well-intentioned window of sufficiently small size could become difficult for a user to find and close.

Maybe a lightBox or simpleModal type solution would be helpful? You'd have more control over the size of the display area.

Upvotes: 5

casablanca
casablanca

Reputation: 70701

No, this is just the way it works. The "features" that you pass in to window.open are simply requests, and the browser is free to ignore any or all of them. Most browsers and/or the underlying OS itself impose a minimum width and height for windows -- there is nothing you can do to alter this via JavaScript.

Upvotes: 6

Related Questions