Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable maximize option in browser using javascript

How to disable maximise option in browser using javascript. I have tried the below code but is not working in some browsers. Is there any other option?

function onReady() {
window.open("https://www.google.com.au","myWindow","resizable=no");
}
like image 511
Jithesh Gopinathan Avatar asked Dec 23 '16 10:12

Jithesh Gopinathan


People also ask

How do I disable maximize button in Chrome?

Open Google Chrome. Enter chrome://flags in the address bar. Search for "Touch UI Layout" Ensure Touch UI is disabled or set to default.

How do I disable the close button on my browser?

No, you can't disable the close button on any web site. This would be a major security concern. You can, however, use onbeforeunload to ask the user if they really want to leave, but they can still continue to close the window if they desire.


2 Answers

You probably can't do that anymore.

According to MDN, the dialog option will do that, but it will only remove the buttons, not the menu commands for it.

function onReady() {
    window.open("https://www.google.com.au","myWindow","dialog=yes,resizable=no");
}

But, you can only use it with "Chrome" privileges, which you probably don't have.


Also be aware that if you're calling this in response to jQuery's ready pseudo-event as the name of the function implies, at least some browsers will prevent your code from opening that window because it's not in direct response to a user event. But if you're calling it in response to a user event, that's not an issue.

like image 169
T.J. Crowder Avatar answered Oct 20 '22 18:10

T.J. Crowder


You cannot (consistently). Deliberately malicious actions are generally restricted by browsers.

But what You can do is..

window.open("mypage.html","mywindowname", "toolbar=no,menubar=no");

WIll give you a new window without the menubar and without the toolbar. If you just want to disable the functionality while still showing the buttons, then you can't.

Look Here for a reference on the window.open() method.

like image 36
Dip Parmar Avatar answered Oct 20 '22 19:10

Dip Parmar