Reputation: 11
I am trying to use JavaScript to make a lightwindow display on the first time a user visits the site. I am using cookies but currently my code currently is set to open a pop-up window using the window.open method. I want to replace the window.open method with a lightbox I have borrowed from this site http://www.p51labs.com/lightwindow/. Can anyone help me to replace the window.open method with a function call to open the lightbox instead?
Here is relevant the code which detects is if the user is a first time visitor and opens the pop-up:
function checkCount() {
var count = GetCookie('count');
if (count != null) {
count=1;
SetCookie('count', count, exp);
window.open(page, "", windowprops);
} else {
count++;
SetCookie('count', count, exp);
}
}
...and this is a quote from the programmer who created the lightwindow as to how to
"Create and Launch a Window with a Javascript Call
To do this simply call activateWindow(id, options) function as show below. Just be sure to reference the myLightWindow object that is automatically created or use the one you have opted to.
myLightWindow.activateWindow({
href: 'http://stickmanlabs.com/images/kevin_vegas.jpg',
title: 'Waiting for the show to start in Las Vegas',
author: 'Jazzmatt',
caption: 'Mmmmmm Margaritas! And yes, this is me...',
left: 300
});"
Thanks in advance for any help!
Upvotes: 1
Views: 2397
Reputation:
hy don't you just replace the code?
window.open(page, "", windowprops);
to
myLightWindow.activateWindow({
href: page,
title: 'Your title',
author: 'Your name',
caption: 'Sometext'
});"
Of course you have to initiate the window first, in order to make it work. (Sorry for my bad english). It is written on the page you mentioned: http://www.p51labs.com/lightwindow/#howtouse
Edit: No, this way you don't need to initiate the window first. If the code above doesn't work it seems like you didn't include the LightWindow scripts.
Upvotes: 0