admin管理员组

文章数量:1287561

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("","myWindow","resizable=no");
}

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..au","myWindow","resizable=no");
}
Share Improve this question edited Dec 23, 2016 at 10:56 A user 1,1083 gold badges20 silver badges47 bronze badges asked Dec 23, 2016 at 10:12 Jithesh GopinathanJithesh Gopinathan 4485 silver badges20 bronze badges 6
  • By maximize you mean fullscreen? Or "resize browser to screen size"? – Foaster Commented Dec 23, 2016 at 10:14
  • so in which browsers it worked? and in which browsers it didnt work? – A user Commented Dec 23, 2016 at 10:14
  • stackoverflow./questions/2048935/… Does this help you? You can implement the answer counter wise – A user Commented Dec 23, 2016 at 10:16
  • @Foaster I dont want the browser size to be changed. – Jithesh Gopinathan Commented Dec 23, 2016 at 10:19
  • 1 This is a horrible idea and it's good it can't be done, you just can't interfere with user devices like that... If any page would do things like that I would close it and never open again... You should rather cater every resolution or point the user to the right one, when things like portrait VS landscape are your problem. But just resizing his browser window to YOUR needs is a big nonono from me and every sentient web dev... – Foaster Commented Dec 23, 2016 at 10:26
 |  Show 1 more ment

3 Answers 3

Reset to default 3

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 mands for it.

function onReady() {
    window.open("https://www.google..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.

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.

Try this

window.onresize = function() 
{
 window.resizeTo(500,500);
}
window.onclick = function() 
{
  window.resizeTo(500,500);
}

</script>

本文标签: jqueryHow to disable maximize option in browser using javascriptStack Overflow