A better vote popup system

There are a LOT of awesome servers out there currently, one of the best ways to find them is using Blockheadsfans. However, the servers that rise to the top there usually have an incredibly annoying “Vote for our server” popup. It appears every time you join the server even if you have already voted today. Here is my attempt to rectify that situation.

This script must be included somewhere in your page, you also need a div with the id of “tymessage” for the thank you message to appear.

This script will work on both locally hosted welcome messages (within the blockheads app) and externally hosted messages (redirecting the page elsewhere)

    //Set this to the message which will be displayed asking players to vote
    var votemessage = "Please vote for our server!";
    //Set this to the number of days until server members are prompted to vote for your server again
    var days = 1;
    //Set this to the URL of your voting page.
    var url = "http://blockheadsfans.com/servers/";
    //Set this to a message to display if the user has voted in the past x days, can be left blank
    var tymessage = "Thank you for voting!";
    //Set this to the tag the message should be displayed in. p is default if left blank.
    var tytag = "";
    //You should not need to change code beyond this line. All configuration is above. 

    function setCookie(cname,cvalue,exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays*24*60*60*1000));
        var expires = "expires=" + d.toGMTString();
        document.cookie = cname+"="+cvalue+"; "+expires;
    function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1);
            if (c.indexOf(name) == 0) {
                return c.substring(name.length, c.length);
        return "";
    function checkVote() {
        var day=getCookie("day");
        if (day != "") {
            //Display if the user has voted
            if (tymessage != "") {
                if (tytag == "") {
                    document.getElementById("tymessage").innerHTML = "<p>" + tymessage + "</p>";
                } else {
                    document.getElementById("tymessage").innerHTML = "<" + tytag + ">" + tymessage + "</" + tytag + ">";
            } else {
                document.getElementById("tymessage").style.display = "none";
        } else {
            //If the user agrees to vote send them to the vote page and set the day cookie
            if (confirm(votemessage) == true) {
                setCookie("day", Date(), days);

   if (window.addEventListener) { // Mozilla, Netscape, Firefox
        window.addEventListener('load', checkVote, false);
    } else if (window.attachEvent) { // IE
        window.attachEvent('onload', checkVote);


<!--Do not remove this div if you want to use the thank you message. It can be placed anywhere in your page.-->
<div id="tymessage"></div>

I threw this together in about 30 minutes with some help from W3 schools :slight_smile:

If there is any change you would like to suggest or if you need a custom script for your specific needs, please let me know!

This has been tested in a SP world – I haven’t tested it live on a server yet. If anyone can confirm that it works that would be great!


Update log:
April 7: 11:13 AM, original post, code V1.0
April 7: 9:34 PM, code V1.1 – now works without an external page.

1 Like

Sorry for the bump but why does no one see this thread? It can be useful for servers, this thread has not even 1 like!

Because this was posted before the migration to the new forums, discourse. There were no likes back then. :slight_smile:


I use this on my servers. It’s used on UNIHORSE!!, Survival of Time, and more I’m sure.

1 Like

This is awesome, only issue I see is that voting can be done every 6 hours :frowning:

Wait, how is that an issue?

1 Like