简体   繁体   English

如何使用 javascript 或 jquery 在页面加载时禁用浏览器最小化、最大化和关闭按钮

[英]How to disable browser minimize, maximize and close button on page load using javascript or jquery

在任何浏览器中禁用页面加载最小化、最大化和关闭按钮。

I don't think you can alter these settings on an existing window but you can affect these settings on a window that your code creates using the window.open() method.我认为您不能在现有窗口上更改这些设置,但是您可以在代码使用 window.open() 方法创建的窗口上影响这些设置。

See Window.open() on MDN .请参阅MDN 上的 Window.open() There are a ton of options you can set and mileage may vary per browser.您可以设置大量选项,并且每个浏览器的里程可能会有所不同。 ie it may not work in all cases.即它可能不适用于所有情况。 Also take note of the usability issues of window.open() in the same article.还要注意同一篇文章中 window.open() 的可用性问题

example:例子:

window.open('http://www.google.com', 'WindowName', 'minimizable=no,scrollbars=no,resizable=no,titlebar=no,location=no')

It did not work exactly as expected in my tests with Chrome.在我对 Chrome 的测试中,它没有完全按预期工作。 eg turning off the location bar resulted in a read only location bar rather than removing it altogether.例如,关闭位置栏会导致只读位置栏,而不是完全删除它。 Other options were seemingly ignored.其他选项似乎被忽略了。 I think many A-Grade browsers are dropping support for this sort of thing due to potential for abuse from malicious sites.我认为许多 A 级浏览器由于可能被恶意站点滥用而正在放弃对此类事情的支持。

By default, max button of a window is enabled, but if you open as pop-up and pass some value as the window property in that case the max button might be disabled, please see below way to do this job:默认情况下,窗口的最大按钮是启用的,但如果您以弹出窗口的形式打开并传递一些值作为窗口属性,在这种情况下,最大按钮可能会被禁用,请参阅下面的方法来完成这项工作:

Set window resizable property as either no or 0.将窗口可调整大小属性设置为 no 或 0。

Format: window.open("pageurl","PopupWindow","resizable=no");格式:window.open("pageurl","PopupWindow","re​​sizable=no"); //OR: resizable=0 Examples: //OR: resizable=0 示例:

window.open(" http://www.google.com ","PopupWindow","resizable=0"); window.open(" http://www.google.com ","PopupWindow","re​​sizable=0"); window.open(" http://domainname.com/somepage.ext ","PopupWindow","resizable=0"); window.open(" http://domainname.com/somepage.ext ","PopupWindow","re​​sizable=0"); window.open(" http://domainname.com/somepage.ext ","PopupWindow","resizable=no"); window.open(" http://domainname.com/somepage.ext ","PopupWindow","re​​sizable=no");

releated posts相关帖子

http://forums.asp.net/t/1474854.aspx http://forums.asp.net/t/1474854.aspx

How To Disable Button Close On Browser For Web Application? 如何禁用 Web 应用程序浏览器上的按钮关闭?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM