It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

I need to know if the user close the browser or to open the

I need to know if the user close the browser or to open the

Postby yaniv11 on Sun Apr 05, 2009 10:43 am

Hello
I need to know if the user close the browser or to open the window – browser without or with a disable close window button –
How can I???
yaniv11
 
Posts: 1
Joined: Sun Apr 05, 2009 10:26 am

Re: I need to know if the user close the browser or to open the

Postby rangana on Wed Apr 08, 2009 7:11 am

- I need to know if the user close the browser:
Code: Select all
<script type="text/javascript">
   window.onbeforeunload = function () {
      return "Do you really want to close this window?";
   }
</script>


- or to open the window – browser without or with a disable close window button:
You can disable the resize button (on IE), but you cannot disable the close button, try:
Code: Select all
<script type="text/javascript">
function openWin(obj) {
   window.open(obj.getAttribute('href'),'window_name',
    "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=no");
}
</script>
<a href="http://www.google.com" onclick="openWin(this);return false;">Open Google</a>


Hope that helps.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: I need to know if the user close the browser or to open the

Postby Suffer on Wed Apr 08, 2009 7:12 am

i think that it good idea!
Suffer
100+ Club
 
Posts: 236
Joined: Tue Jan 20, 2009 6:34 am

Re: I need to know if the user close the browser or to open the

Postby xdeveloper on Fri Apr 10, 2009 6:24 am

Code: Select all
window.onbeforeunload = function () {
     if(confirm('Are you sure you want to close this window'))
      return true;
   }
else
{
   return false;
}


this method is calls when the
window.close
method occurs
xdeveloper
 
Posts: 1
Joined: Fri Apr 10, 2009 6:12 am


Who is online

Users browsing this forum: psbot [Picsearch] and 5 guests