Click here to Skip to main content
13,050,896 members (63,668 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I want to disable the window browser close(X) while I am opening my ModalDialog box, which is small in size and contains buttons for OK and Close.

When the user clicks the 'Close' button the child page should be closed. It should not get closed while they are clicking browser close button.

<script language="javascript" type="text/javascript">
        function Onclick()

        RetVal = window.showModalDialog("CabinMappingChild.aspx","CabinMapping","dialogHeight: 190px; dialogWidth: 550px; titlebar: no; toolbar: no; statusbar:no");

I am using the above code but still I could not get it to work.

Can anyone please help me?
Posted 1-Sep-10 1:55am
Updated 1-Sep-10 2:28am
Sandeep Mewara 1-Sep-10 16:47pm
Follow up question by OP:
No... i don;t want full screen option.....
Ok... is it possible to write function definition for (like in javascript) while user clicking browser close(x)???
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You are not allowed to disable the close button in the browser for security reasons.

However... You can open the window in fullscreen size which means the browser automatically will hide the titlebar and the minimize, maximize, and close buttons!

To open a webform in fullscreen see below:'WebForm2.aspx', '', 'Fullscreen=yes');

Hope that helps!
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Its not working on my button click event...
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

YOU CAN disable parent window.. See this link.[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 12 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100