/    Sign up×
Community /Pin to ProfileBookmark

Pop up that displays only if cookie not present

Hi Guys first time on the forum so please forgive my ignorance.
I’ve put togethere a form with a script that creates a cookie when users select various options. The form is going to appear in a popup (i’m using colorbox jquery for this). I can get the popup form to appear when people visit my target page but what I can’t seem to get right is a script that first checks if my cookie is present, and if it isn’t then fire up my popup.
Here is what i have so far and would greatly appreciate any guidance you can offer me.

window.onload = function(){

if(document.cookie)
{
index = document.cookie.indexOf(Survey);
if (index != -1)
{
$(document).ready(function() {
$.fn.colorbox({href:’survey.htm’, open:true});
});
}
}
}

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@pandyalmerauthorNov 18.2009 — Finally brute force and ignorance have prevailed! ?

I found another script at; http://codingforums.com/showthread.php?t=13708 and amaneded it.

function get_cookie(Name) {

var search = Name + "="

var returnvalue = "";

if (document.cookie.length > 0) {

offset = document.cookie.indexOf(search)

if (offset != -1) {

offset += search.length

end = document.cookie.indexOf(";", offset);

if (end == -1)

end = document.cookie.length;

returnvalue=unescape(document.cookie.substring(offset, end))

}

}

return returnvalue;

}

function loadornot(){

if (get_cookie('Survey')==''){

$(document).ready(function() {

$.fn.colorbox({href:'survey.htm', open:true});

});

}

}

loadornot()
×

Success!

Help @pandyalmer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...