Please anyone provides code with examle to disable the Close (X) button in title bar. If user wants to click automatically a dialog box must appear with message 'This is disbale'...

Thanks

Recommended Answers

All 4 Replies

Immediate thought

Malwareyou cant close this page unless you buy something
your pc is infected send us moneyYou are not supposed to take control of the browser
Imagine if you could not close a web browser when you went to some site on the internet that was loading your computer full of viruses!

lookup

onclose
onunload

something like

<script language="JavaScript">
<!-- 
var legalExit=0;
var lpx=10;
 function leave() {
if(legalExit==0) {
var dl=confirm('WARNING: Closing this window means bla bla bla.\n\nClick OK to remain.'); 
if(dl) {
if(window.screen){ 
lpx=screen.width;lpx=lpx-225;
} 
var op=window.open('filename','','width=170,height=185,location=no,status=no,directories=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,top=10,left=' + lpx);
}
}
}
 function openWin(u,t,x,y,s) { 
var op=window.open(u,t,'width='+x+',height='+y+',location=no,status=yes,toolbar=no,directories=no,menubar=no,scrollbars='+s+',resizable=no'); 
op.focus();
}
// -->
</script>

code is untested, just thought process

Thanks almostbob...

But this does not help me much. My browser window will contain all features as menubar, addressbar, standard button all... but this browser should not allow the user to close on clicking close (X) button. at time time a pop up massage appears with 'User cannot click on this Close Button'. the user must select the logOut menu to sign out.

Please send the code if you have.

Thanks -- ukbasak

YOU CAN TRY WITH BELOW SCRIPT.
JUST PASTE THE BELOW SNIPPET WITHIN HEAD TAG:

window.onbeforeunload = confirmExit;
function confirmExit()
  {
    if (window.event.clientY < 0 && window.event.clientY < -80) 
    { 
        return 'You will be logged out.';
        // You can set return false here.
    } 
  }

Perhaps look into sessions, no experience to offer but.,,
it
logs them out of the server after time of no activity
whether they click the bye-bye button or no

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.