LOLWesta, a social media forum


You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

1
Unload problem on Sun Sep 21, 2014 11:16 am

How to make this working?

Code:
$(window).unload(function() {
confirm("Exit confirm");
if(confirm == ok) {
window.close;
}else{
return false;
});

View user profile

2
Re: Unload problem on Sun Sep 21, 2014 11:21 am

LOLWesta


LOLWesta King
Oh, how can I explain this..

Okay, ehem. Actually, JQuery IS Javascript. You can mix them no problem at all really, and really that's not a different language. JQuery is a language that created using Javascript so yes you can use Javascript inside Jquery as long as the syntax is legal to use. See more here : http://w3schools.invisionzone.com/index.php?showtopic=46447

Ahem. Where are you using this code? In your forum? Or anywhere else?

View user profile http://lolwesta.forummotions.com

3
Re: Unload problem on Sun Sep 21, 2014 11:33 am

Ah, perfect. I won't open the site because I've really hate W3Schools but that's what I'm currently looking for. Thanks. And I'll use that at my forum, my web server too.

View user profile

4
Re: Unload problem on Thu Sep 25, 2014 8:23 am

LOLWesta


LOLWesta King
Do you have jQuery installed on your forum / website?

View user profile http://lolwesta.forummotions.com

5
Re: Unload problem on Fri Sep 26, 2014 7:38 am

sugar


Members
Members
if you want my script, here's mine Smile it does the same for your script

Code:
$(function() {
$(window).unload(function() {
e.preventDefault();
confirm('testing confirm');
if(confirm == yes) {
window.close;
}else{
return false;
}
});

that's mine Smile it looks like your script like ? well i just edited your script, am i allowed to copy your script and apply them into my website ?

View user profile

6
Re: Unload problem on Tue Dec 23, 2014 6:03 am

LOLWesta


LOLWesta King
Nope, nope. If you do that way, then the JavaScript will search for the variable named 'e'. You can just do something like

Code:
$(function() {
$(window).unload(function() {
event.preventDefault();
confirm('Lorem ipsum dolor sit amet. Click OK if you agreed.');
if(confirm == 'OK') {
window.close;
}else{
return false;
}
});
});

Remember; don't do some syntax error. You'll forget to close the 'window unload' and the 'document.ready' command. It will results some syntax error.

View user profile http://lolwesta.forummotions.com

7
Re: Unload problem on Wed Dec 24, 2014 10:54 am

Tsu


Members
Members
Code:
$(function() {
$(window).unload(function() {
//stuffs here, in this example I just do some alert
alert('Bye now!');
});
});

View user profile

8
Re: Unload problem on Fri Jan 02, 2015 12:37 pm

sugar


Members
Members
we can do something with onbeforeUnload that are written here

Code:
window.onbeforeunload = function(e) {
return 'are you sure ? your data will be lost !'
};

View user profile

9
Re: Unload problem on Sat Jan 17, 2015 11:45 am

Left


Members
Members
Don't forget to use the parameter e Wink

Code:
window.onbeforeunload = function(e) {
 e.preventDefault();
 confirm('Are you sure?');
 if(confirm == ok) {
  window.close
 }
};

View user profile

Sponsored content


View previous topic View next topic Back to top Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum