Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [ZB] Special Popup + message
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[Completed] [ZB] Special Popup + message
Tweet Topic Started: Oct 6 2009, 07:32 PM (254 Views)
Swordslam46 Oct 6 2009, 07:32 PM Post #1
Member Avatar


Posts:
934
Group:
Dedicated
Member
#2,773
Joined:
Apr 9, 2009
Is there a way to make a code that makes a pop-up come up witha message(50% chance) and a message being sent to the admin. If the message cant be sent Im ok with that.
Offline Profile Goto Top
 
Reid Oct 6 2009, 09:07 PM Post #2
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
So does this chance happen on every page, and if it happens once to one user then can it happen to another user?
The Resource Board
Offline Profile Goto Top
 
Swordslam46 Oct 7 2009, 03:57 PM Post #3
Member Avatar


Posts:
934
Group:
Dedicated
Member
#2,773
Joined:
Apr 9, 2009
Not on every page, only when posting. And yes it can happen to every member, even if 1 member has already gotten it.
Offline Profile Goto Top
 
Reid Oct 7 2009, 04:32 PM Post #4
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Code:
 
<script type='text/javascript'>
// <![CDATA[
var some_msg = "You have won the lottery. Congratulations!\n\n(I was joking. You didn't.)";
var name_of_admin = "Reid";
var msg_title = "I win!";
var msg_template = "I win at life. My message was, however, '{{msg}}'";
// end of options
if (location.href.indexOf('/post')!=-1 && Math.floor(Math.random()*100) >= 50) {
alert(some_msg);
$.get(main_url + 'msg/?c=2', function(r) {
$.post(main_url + 'msg/?c=3&sd=1', { xc:$('input[name=xc]',r).val(), msg:0, fwd:0, convo:0, draft_edit:0, secure:$('input[name=secure]',r).val(), name:name_of_admin, title:msg_title, post:msg_template.replace(/\{\{msg\}\}/g, some_msg) });
});
}
// ]]>
</script>
That should do it.

Of course, there are a few options. some_msg is the message you want to pop up. name_of_admin is the admin you want the PM sent to. msg_title is the title of the PM sent to the admin. msg_template is the template for the PM that's being sent.

Note that in order to create a new line, use \n - that's a backslash then a n. I gave you an example in the some_msg. :)

In the msg_template, {{msg}} will be replaced by some_msg, so if you have multiple competitions with this going on or something, then you'll be able to tell who won what. Also, 50% is a mighty high chance so you might want to make that lower. In order to lower the chance, edit the part that says
Code:
 
>= 50
And you can change the 50 to anything you want.
The Resource Board
Offline Profile Goto Top
 
Swordslam46 Oct 7 2009, 06:30 PM Post #5
Member Avatar


Posts:
934
Group:
Dedicated
Member
#2,773
Joined:
Apr 9, 2009
Where does this go? Above the copyright?
Offline Profile Goto Top
 
Reid Oct 7 2009, 06:37 PM Post #6
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Yeah, or below the board. Doesn't really matter.
The Resource Board
Offline Profile Goto Top
 
Choco Oct 20 2009, 04:33 PM Post #7
Member Avatar
¡ʎɹoʇɔɐɟ ʎʇıʌɐɹƃ ɐ uı pǝddɐɹʇ ɯ,ı 'dןǝɥ

Posts:
589
Group:
Admins
Member
#3,272
Joined:
Jun 30, 2009
Coding language
Everything
You're welcome.
See? We can read thoughts too. ;)

Your request has been completed, and we're moving it to the correct forum. We hope it works for you; if it doesn't, feel free to post another request topic in the requests forum. Just remember: read the rules first!

Thanks,
The ZBCode Staff
Posted ImageIt's a magical world, Hobbes, ol'd buddy... ...let's go exploring!
In progress: Something Special ;)
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Completed Requests · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 2:27 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy