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='jav开发者_StackOverflowascript:void(0)' onclick=openWindow('http://www.stackoverflow.com')> Open the window </a>
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.
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.
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)
精彩评论