I tried that, but it doesn't hide the box. Box still closes by clicking on the image, and the cookie shows up in my browser's cookie list, but...
Main Topics
Browse All TopicsI'm using a standard JS popup-once cookie script, from www.yaldex.com. However, it is designed to popup a new window one time only. Instead, I am popping up a CSS layer. I need to modify the script to trigger the "hide" function if the visitor has been to the site before. I am not a JS programmer, I am sort of cobbling together some different things, and trying to make them work.
Here's the relevant sections of code:
- - - Checks Cookie and runs WindowOpen if haven't been there before - - -
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);
}
}
- - - current code to close CSS layer by clicking on Image - - -
<td style="cursor:hand"><a href="#" onClick="hidebox();return false"><img src="close.gif" width="16px" height="14px" border=0></a></td>
- - - code of hidebox() function - - -
function hidebox(){
crossobj=ns6? document.getElementById("s
if (ie4||ns6)
crossobj.style.visibility=
else if (ns4)
document.showimage.visibil
}
- - - - - -
Seems like if I could replace the "window.open(page, "", windowprops);" with something that triggers the hidebox() function, I would be set.
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtm
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="REMOVED" />
<meta name="Description" content="REMOVED." />
<title>REMOVED</title>
<script type="text/javascript">
/*************************
* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
* Visit http://www.dynamicdrive.co
* This notice must stay intact for use
**************************
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementByI
//drag drop function for NS 4////
//////////////////////////
var dragswitch=0
var nsx
var nsy
var nstemp
function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.M
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}
function gons(e){
temp.captureEvents(Event.M
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-ns
return false
}
}
function stopns(){
temp.releaseEvents(Event.M
}
//drag drop function for ie4+ and NS6////
//////////////////////////
function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+
crossobj.style.top=tempy+e
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+
crossobj.style.top=tempy+e
return false
}
}
function initializedrag(e){
crossobj=ns6? document.getElementById("s
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="Back
while (firedobj.tagName!=topelem
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}
if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY
tempx=parseInt(crossobj.st
tempy=parseInt(crossobj.st
dragapproved=true
document.onmousemove=drag_
}
}
document.onmouseup=new Function("dragapproved=fal
////drag drop functions end here//////
function hidebox(){
crossobj=ns6? document.getElementById("s
if (ie4||ns6)
crossobj.style.visibility=
else if (ns4)
document.showimage.visibil
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
var expDays = 1; // number of days the cookie should last
var page = "http://www.yaldex.com";
var windowprops = "width=300,height=200,loca
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.s
}
function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);
alert('count = 1')
}
else {
count++;
SetCookie('count', count, exp);
}
}
window.onload=checkCount;
// End -->
</script>
// BUNCH OF HTML
<!-- Begin popup for subscription -->
<div id="showimage" style="position:absolute;w
<table border="0" width="250" bgcolor="#478C9B" cellspacing="0" cellpadding="2">
<tr>
<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"
height="36px">
<tr>
<td id="dragbar" style="cursor:hand; cursor:pointer" width="100%" onMousedown="initializedra
<td style="cursor:hand"><a href="#" onClick="hidebox();return false"><img src="close.gif" width="16px"
height="14px" border=0></a></td>
</tr>
<tr>
<td width="100%" bgcolor="#FFFFFF" style="padding:4px" colspan="2">
<!-- PUT YOUR CONTENT BETWEEN HERE -->
<form action="http://www.someweb
<table width="212"
border="0" cellspacing="0" cellpadding="0"> <tr> <td width="75"><div
align="right">E-mail</div>
name="email" type="text" id="email" value="" size="16"> </div></td> </tr>
<tr> <td width="75"><div align="right">Name</div></
align="right"> <input name="name" type="text" id="name" value=""
size="16"> </div></td> </tr>
<tr>
<td width="75"><div align="right"> </div></td>
<td> <div align="left">
<input name="funcml" type="radio" value="add" checked>Subscribe</div></t
</tr> <tr> <td width="75"><div align="right"> </div></td> <td> <div
align="left"> <input name="funcml" type="radio"
value="unsub2">Unsubscribe
align="right"> <input name="p" type="hidden" id="p" value="21">
<input type="hidden" name="nlbox[1]" value="53">
</div></td>
<td> <div align="right">
<br>
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>
<!-- END YOUR CONTENT HERE -->
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
Did you load into a page and view in a browser? You'll see that there's a form that pops up. If you click to submit the form (calling hidebox()), or click in the top right corner of the form (also calling hidebox()), the form goes away. I want it to go away if they have been to the site before as well.
In other words, it's not hidden until hidebox() is called...
I got the alert the first time and not the other times. So I guess it's working.
Oh, I see, you inversed your rules... This is how checkcount should be:
function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);
} else {
count++;
SetCookie('count', count, exp);
hidebox();
}
}
Business Accounts
Answer for Membership
by: cLFlaVAPosted on 2006-07-27 at 11:59:19ID: 17195575
replace this:
window.open(page, "", windowprops);
with this:
hidebox();