Reputation: 1031
Can I disable close button in IE using javascript? maybe like "Resizeable =no ". But i dont want to use "fullscreen = yes". How ?
Thx
Upvotes: 1
Views: 8425
Reputation: 10548
This is impossible in modern browsers. Browser makers want to provide a user-friendly and relatively predictable experience, which includes not making features that would be useful primarily to makers of spyware or heavily obnoxious, impossible-to-close-without-clicking ads.
Upvotes: 13
Reputation: 3958
If this is for an intranet site or a kiosk, you can use HTML Applications. HTML Applications are just HTML files that can be made to look and feel like regular Windows applications.
If, for example, you want a full screen Kiosk application just install a proper HTA file on the computer at runs on start up with the following configuration in the head section:
<HTA:APPLICATION ID="MyApp"
APPLICATIONNAME="Kiosk"
BORDER="none"
CAPTION="no"
ICON="/graphics/creature.ico"
SHOWINTASKBAR="no"
SINGLEINSTANCE="yes"
SYSMENU="no"
WINDOWSTATE="maximize">
The Border="none" part makes a window that doesn't have a close button.
Remember though, this wont work on a regular web page because disabling the close button is a dangerous thing for an untrusted web page to do. By using an HTA you tell Windows that you can trust this page.
The HTA reference is here: http://msdn.microsoft.com/en-us/library/ms536473%28VS.85%29.aspx
And a tutorial: http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx
Upvotes: 2
Reputation: 8928
The best you can do is to capture the user leaving the page and popup a dialog asking them if they're sure they want to. You cannot cancel the event.
Example (works in IE):
window.onbeforeunload = function(evt)
{
if (unsavedData)
{
var message = 'Leaving the page will result in the loss of unsaved data.';
if (typeof evt == 'undefined')
{
evt = window.event;
}
if (evt)
{
evt.returnValue = message;
}
return message;
}
}
Upvotes: 3
Reputation: 4936
For security reason, you cannot do that by just using javascript.
Upvotes: 2