First Time Visitor Popup

Hello … just spent the last four hours trying to come up with a way to display a popup modal with a “first time visitor” greeting.

So the script would check if there is a cookie … if there is, you just get the normal site … if not, you get the “first time visitor” popup.

I gather PHP is the best way to do this … but I don’t have that luxury here. The site is already built so they just requested a javascript solution. I found some plugin type things out there but couldn’t get any of them up and working due to poor directions.

The ColorPop (http://coverpopjs.com/) thing was looking very promising but I could never get the Close Modal button to work.

You can see my efforts here: http://www.savagepixels.com/wti/first-time-visitor-popup-2.html

So, basically I’m clueless on this one and would appreciate any links, or guidance in this area. It doesn’t sound all that hard and maybe that’s why there isn’t a ton of stuff out there. but I’m having difficulty coming up with a solution.

Thanks

JavaScript can access cookies via document.cookie. If you are planting the cookie with a specific name/value pair, a simple indexOf() should let you know if the cookie exists (greater than -1) or not (equals -1). If you’re using JavaScript to plant the cookie, don’t forget to give the cookie an expiration date - lack of date makes it a session cookie that will be cleared as soon as the browser closes.

A fairly good tutorial on JavaScript cookie handling can be found here.

Awesome info. Thanks for your input.

I’m still working with this. The solution I had did not work in IE apparently because of “querySelectorAll” method.

It looks like I need to write this code from scratch to achieve what I need but I’m no where near saavy enough to do that without assistance. Is there any way you could get me going on this? Once I see the code, I can reverse engineer what is happening and understand it, but am nowhere near just writing it off the top of my head.

What I need is a block of code that deploys and then checks for cookies so it can identify first time site visitors. There should be a button in the popup to “dismiss” it. It also needs to work in all modern browsers including IE 8 and up.

Is this possible?

It worked just fine. There was a conflicting meta tag in there telling it to render as an earlier version of IE. Thanks again.