tags:

views:

666

answers:

5

Dear All,

Can I disable close button in IE using javascript? maybe like "Resizeable =no ". But i dont want to use "fullscreen = yes". How ?

Thx

+11  A: 

Pretty sure this is impossible, at least 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.

Ben
+1 agreement =)
thephpdeveloper
+1 Agreed, trying to hide the close button is bad news to say the least.
Nathan Kleyn
+1  A: 

For security reason, you cannot do that by just using javascript.

Henry Gao
A: 

what should i do, if i want to disable IE close button feature

Yayan
Don't do it at all. If the web evangelists find you, they'll murder you on the spot. If people want to close their browser window, they should be able to do that whenever they please.
Nathan Kleyn
Don't ask the question in an Answer, instead use a comment to the specific answer you want clarification on.
wm_eddie
+1  A: 

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;
         }

     }
Coxy
+2  A: 

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

wm_eddie
Might be worth mentioning that this is IE only.
Tim Down
HTAs don't run in IE, so it's not IE only. It's Windows-only.
wm_eddie
OK. I'm no expert on the subject. I recognised the file extension and dimly remembered it as having something to do with behaviours in IE. And I'd be extremely surprised if these HTAs are not using IE.
Tim Down
The program that hosts the HTAs uses the IE rendering engine, but with most restrictions turned off. Regular IE will ignore any HTML files with an <hta:application> tag on the internet, or your local hard drive. They have to have an .hta extension so that a different program loads them.
wm_eddie