The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Logout Popup

3 posters

Go down

Solved Logout Popup

Post by iamthestreets January 19th 2012, 8:16 pm

Is there anyway to edit the logout html to add an onclick function?

I would like to add this to ask my members are they sure they want to logout.
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 19th 2012, 10:21 pm

Rideem3 wrote:Yeah, here's a code that will ask them to confirm their log out Wink

Go to Admin Panel -> Modules -> JavaScript Codes Management -> Create a new JavaScript:
Title: Logout
Check "In All the Pages"

Put this code:
Code:
jQuery(document).ready(function() {
jQuery('a[href*="/login?logout"]').attr({
onclick: "logConfirm()",
id: "logout"
});
});

function logConfirm() {
var x = confirm("Are you sure you want to logout?");
if (x == true) {
return true;
}else{
jQuery(document).ready(function() {
jQuery('#logout').attr({
href: "#"
});
});
}
}

That didn't work.
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by petros_7 January 19th 2012, 10:24 pm

it work Check "In All the Pages"
petros_7
petros_7
Forumember

Male Posts : 341
Reputation : 2
Language : Greek
Location : Greece

http://www.thegreeksenergy.com/forum

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 19th 2012, 10:27 pm

I created a new JS and Checked "In All The Pages". It is not working.
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 19th 2012, 10:34 pm

Rideem3 wrote:All I see on your forum is this:
http://www.mystreetlife.com/99372.js

You must remove:
Code:
$(function(){document.post.post.value="Post"});

Why do i need to remove that for? I use that to change the send button to post. I have a total of 3 JS

Logout http://www.mystreetlife.com/12372.js
Quote Box http://www.mystreetlife.com/11328.js
post instead of send http://www.mystreetlife.com/10000.js

I did create a new javascript
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 19th 2012, 10:50 pm

Still not working. I'm doing everything your saying to do, but its not working.

Confused
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 19th 2012, 10:56 pm

still nothing. scratch
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 19th 2012, 11:06 pm

I have edited some of the templates but I'm not sure what would be blocking it. Is there anything else that you could do?

You are right i have to delete...
Code:
$(function() {
document.post.post.value="Post";
});

for it to work. So maybe you can help me with changing the send to post when people create a new or reply to a topic?

I don't understand why i cant use both js codes if they a seperated? So i was able to get the confirm box to pop up but when i hit cancel it still logs me out ?


Last edited by iamthestreets on January 19th 2012, 11:37 pm; edited 1 time in total (Reason for editing : got it to work a little)
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by LGforum January 19th 2012, 11:46 pm

Its because that script will crash on a page where a send button doesn't exist.
All you need to do is change it to this:
Code:

        $(function() {
if (document.post) {  document.post.post.value="Post"; }
        });


And here is the other code improved on AND with the first code included in it:
So this is the ONLY code you need for these two tasks.
Code:

$(function() {
 if (document.post) {  document.post.post.value="Post"; }
 var x=document.getElementById('logout');
  if (x) {
      $(x.parentNode).click(function(e) {
            if (!confirm("Are you sure you want to logout?")) {  e.preventDefault(); }
      });
  }
});

Sorry for improving your code Rideem3, I meant no offence, but only for educational purposes.
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 20th 2012, 12:19 am

LGforum wrote:Its because that script will crash on a page where a send button doesn't exist.
All you need to do is change it to this:
Code:

        $(function() {
if (document.post) {  document.post.post.value="Post"; }
        });


And here is the other code improved on AND with the first code included in it:
So this is the ONLY code you need for these two tasks.
Code:

$(function() {
 if (document.post) {  document.post.post.value="Post"; }
 var x=document.getElementById('logout');
  if (x) {
      $(x.parentNode).click(function(e) {
            if (!confirm("Are you sure you want to logout?")) {  e.preventDefault(); }
      });
  }
});

Sorry for improving your code Rideem3, I meant no offence, but only for educational purposes.

This works, but if i click on any one of my other buttons like forum, search, etc it opens the confirm box.
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: Logout Popup

Post by LGforum January 20th 2012, 12:43 am

Change (x.parentNode) to just (x)
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Solved Re: Logout Popup

Post by iamthestreets January 20th 2012, 1:06 am

LGforum wrote:Change (x.parentNode) to just (x)

It Worked!!! :wouhou: Thanks goes to both you!
avatar
iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Back to top

- Similar topics

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