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 Empty Unload problem Sun Sep 21, 2014 11:16 am

Test Account


Members
Members
How to make this working?

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

2
Unload problem Empty Re: Unload problem 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?

https://lolwesta.forumotion.com

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

Test Account


Members
Members
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.

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

LOLWesta


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

https://lolwesta.forumotion.com

5
Unload problem Empty Re: Unload problem 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 ?

6
Unload problem Empty Re: Unload problem 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.

https://lolwesta.forumotion.com

7
Unload problem Empty Re: Unload problem 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!');
});
});

8
Unload problem Empty Re: Unload problem 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 !'
};

9
Unload problem Empty Re: Unload problem 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
 }
};

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