Alaa Alweish
Alaa Alweish

Reputation: 9084

javascript (window.open) opens maximized in all browsers but not in chrome

I am using the following code to open a maximized pop up window, i don't want to open it full screen (F11), I need it just maximized, exactly like pressing the button between minimize and close.

<a  onclick="javascript:w= window.open('https://www.facebook.com/mywifemylove','_blank','channelmode =1,scrollbars=1,status=0,titlebar=0,toolbar=0,resizable=1');" href="javascript:void(0);" target="_blank">Maximized on Chrome</a>

It's working fine for all browsers but not Chrome, Here is a jsfiddle for testing

Upvotes: 9

Views: 36236

Answers (5)

Jonathan J. Pecany
Jonathan J. Pecany

Reputation: 313

Unfortunately, I don't think you can actually use it in chrome. I've also tried it but couldn't get it to work in chrome.

I know it is really helpful to actually make it maximize more quickly that makes it so the user don't have to click the button but that is how chrome works.

Here is a jsfiddle example that will be as close as possible to maximization. It is always good to try to make alternative options. Here is the code from the onclick attribute. You can insert all your previous code to that argument as well, just removed that to show what I changed to it.

javascript:w= window.open('https://www.facebook.com/mywifemylove','_blank',`height=${screen.height},width=${screen.width}`);

Here is also a w3School documentation of the arguments as well, just in case you wanna look through it and see what's supported and what is not.

Upvotes: 0

Bunty Kumar
Bunty Kumar

Reputation: 11

You can open window tab with below code:-

window.open(src, "newWin", "width="+screen.availWidth+",height="+screen.availHeight)

Upvotes: 1

Varma
Varma

Reputation: 1

I think following code is helpful to you.

<a  id="popupLink" href="#"> link name</a> 
       jquery.click(function(e){
       e.preventDefault();
       var newTab =window.open('','_blank','channelmode=1,scrollbars=1,status=0,titlebar=0,toolbar=0,resizable=1');
        newTab.location = "https://www.facebook.com/mywifemylove";
        newTab.focus();
});

Upvotes: 0

DanielST
DanielST

Reputation: 14163

With the exception of IE, browsers do not support going fullscreen with JS. This is intentional:

https://developer.mozilla.org/en-US/docs/Web/API/window.open#FAQ

"All browser manufacturers try to make the opening of new secondary windows noticed by users and noticeable by users to avoid confusion, to avoid disorienting users."

You can manually set the size of the window to the screen size but you may have to deal with things like frame border thickness.

Relevant SO question: How to open maximized window with Javascript?

Working code for max size window on latest versions of IE, FF or Chrome:

window.open('http://www.stackoverflow.com','_blank','height='+screen.height+', width='+screen.width);

Upvotes: 10

Bojana Cubranovic
Bojana Cubranovic

Reputation: 39

function openMax() { 
var wihe = 'width='+screen.availWidth+',height='+screen.availHeight; 
window.open("ht*p://www.example.com/", 
"foo", 
"screenX=1,screenY=1,left=1,top=1," + wihe); 
}

Upvotes: 0

Related Questions