I'm using Javascript's self.open()
to open a link in a new window and i'd like that window to be maximized. I tried the fullscreen=yes
option, which really doesn't do what I want. I am using below code:
self.open(pageLoc,popUpName,'height=1600,width=1800,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes');
If i also mention fullscreen=yes
, then window opens up like you press F11. But i don't want it that. What i want is when i double click on IE and click maximize icon on top right corner.
As i have given the height
and width
value so large, it is close to maximized window but not actual maximized window. (the reason i am saying this because
even now if i click maximize button, it further expans little bit)
This question is related to
javascript
internet-explorer
Checkout this jquery window plugin: http://fstoke.me/jquery/window/
// create a window
sampleWnd = $.window({
.....
});
// resize the window by passed w,h parameter
sampleWnd.resize(screen.width, screen.height);
The best solution I could find at present time to open a window maximized is (Internet Explorer 11, Chrome 49, Firefox 45):
var popup = window.open("your_url", "popup", "fullscreen");
if (popup.outerWidth < screen.availWidth || popup.outerHeight < screen.availHeight)
{
popup.moveTo(0,0);
popup.resizeTo(screen.availWidth, screen.availHeight);
}
see https://jsfiddle.net/8xwocrp6/7/
Note 1: It does not work on Edge (13.1058686). Not sure whether it's a bug or if it's as designed (I've filled a bug report, we'll see what they have to say about it). Here is a workaround:
if (navigator.userAgent.match(/Edge\/\d+/g))
{
return window.open("your_url", "popup", "width=" + screen.width + ",height=" + screen.height);
}
Note 2: moveTo
or resizeTo
will not work (Access denied) if the window you are opening is on another domain.
window.open('your_url', 'popup_name','height=' + screen.height + ',width=' + screen.width + ',resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes')
If I use Firefox then screen.width
and screen.height
works fine but in IE and Chrome they don't work properly instead it opens with the minimum size.
And yes I tried giving too large numbers too like 10000
for both height
and width
but not exactly the maximized effect.
Source: Stackoverflow.com