Dont tell me again Link!!!

  • fspigroup
  • Newbie
  • Newbie
  • fspigroup
  • Posts: 6
  • Loc: Manchester Uk

Post 3+ Months Ago

hi everyone

I was wondering if anyone knows of a way i can put a

"Dont tell me again" link on a pop up window i have on my site?

At the moment my site is being updated and i have a pop up window that shows when someone goes to my site, however i am wondering how i can only make it pop up once per user.

Thanks

DB
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9092
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

So I want to be clear. Once they see the popup and leave your site, then the next time they come to your site you do not want the popup showing because they have already seen it correct?

If that is the case you could do this by setting a cookie in their browser which pretty much says they have seen the popup. Then when they visit your website before you popup the popup, make sure your code checks their cookie first and sees if they need it popped.
  • fspigroup
  • Newbie
  • Newbie
  • fspigroup
  • Posts: 6
  • Loc: Manchester Uk

Post 3+ Months Ago

thanks Biggie

I have never used cookies before and have no idea what to do.

I am not using php and everything is raw html.

I will post link to the temp url so you can get a better idea of it all.

Thanks again.

DB

http://host.deluxnetwork.com/~antzoo
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9092
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Yeah well you don't need php, perl, or any other CGI to do it. You can set cookies with javascript too, which is what you are using to popup that window :wink:

Here is how you can do it. There are two parts you must do. Copy one part into your head tag, and then for the second part you must add something in your body tag. Also make sure you edit some of the code so that it popus the right page. Thus you will need to enter the name of the html page you want to popup in the first code. Here is the steps and code:

1. Copy the coding into the HEAD of your HTML document

Code: [ Select ]
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
<!--
var expDays = 1; // number of days the cookie should last

var page = "nameOfYourPopup.html";
var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";

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(i, j) == arg)   
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,exp)
return count
  }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

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);
  }
}
// End -->
</script>
  1. <!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
  2. <SCRIPT LANGUAGE="JavaScript">
  3. <!--
  4. var expDays = 1; // number of days the cookie should last
  5. var page = "nameOfYourPopup.html";
  6. var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";
  7. function GetCookie (name) { 
  8. var arg = name + "="; 
  9. var alen = arg.length; 
  10. var clen = document.cookie.length; 
  11. var i = 0; 
  12. while (i < clen) {  
  13. var j = i + alen;  
  14. if (document.cookie.substring(i, j) == arg)   
  15. return getCookieVal (j);  
  16. i = document.cookie.indexOf(" ", i) + 1;  
  17. if (i == 0) break; 
  18. return null;
  19. }
  20. function SetCookie (name, value) { 
  21. var argv = SetCookie.arguments; 
  22. var argc = SetCookie.arguments.length; 
  23. var expires = (argc > 2) ? argv[2] : null; 
  24. var path = (argc > 3) ? argv[3] : null; 
  25. var domain = (argc > 4) ? argv[4] : null; 
  26. var secure = (argc > 5) ? argv[5] : false; 
  27. document.cookie = name + "=" + escape (value) +
  28. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  29. ((path == null) ? "" : ("; path=" + path)) + 
  30. ((domain == null) ? "" : ("; domain=" + domain)) +  
  31. ((secure == true) ? "; secure" : "");
  32. }
  33. function DeleteCookie (name) { 
  34. var exp = new Date(); 
  35. exp.setTime (exp.getTime() - 1); 
  36. var cval = GetCookie (name); 
  37. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  38. }
  39. var exp = new Date();
  40. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  41. function amt(){
  42. var count = GetCookie('count')
  43. if(count == null) {
  44. SetCookie('count','1')
  45. return 1
  46. }
  47. else {
  48. var newcount = parseInt(count) + 1;
  49. DeleteCookie('count')
  50. SetCookie('count',newcount,exp)
  51. return count
  52.   }
  53. }
  54. function getCookieVal(offset) {
  55. var endstr = document.cookie.indexOf (";", offset);
  56. if (endstr == -1)
  57. endstr = document.cookie.length;
  58. return unescape(document.cookie.substring(offset, endstr));
  59. }
  60. function checkCount() {
  61. var count = GetCookie('count');
  62. if (count == null) {
  63. count=1;
  64. SetCookie('count', count, exp);
  65. window.open(page, "", windowprops);
  66. }
  67. else {
  68. count++;
  69. SetCookie('count', count, exp);
  70.   }
  71. }
  72. // End -->
  73. </script>


2. Add the onLoad event handler into the BODY tag

Code: [ Select ]
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY OnLoad="checkCount()">
  1. <!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
  2. <BODY OnLoad="checkCount()">


Let me know if this solves your problem :)
  • fspigroup
  • Newbie
  • Newbie
  • fspigroup
  • Posts: 6
  • Loc: Manchester Uk

Post 3+ Months Ago

hello again,

Thanks for the code, i changed a few things as you said:

Quote:
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
<!--
var expDays = 1; // number of days the cookie should last

var page = "nameOfYourPopup.html";


to

Quote:
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
<!--
var expDays = 7; // number of days the cookie should last

var page = "notice.html";


i have also added the rest of the code to the head and also the other code to the body,

Do i have to take out the javascript i currently use for the pop up window?
is there anything else i have to change?

Thanks again.

the website url is http://www.antzoo.com

DB
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9092
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Yeah I would take out your old code, and then use that code, and modify it some.
  • fspigroup
  • Newbie
  • Newbie
  • fspigroup
  • Posts: 6
  • Loc: Manchester Uk

Post 3+ Months Ago

Unfortunatly this did not work for me, i have modified the code to the best of my knowledge,

Could you take one last look at my source code and see if you see anything?

Thanks

DB
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9092
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Make sure you do step 2 and add that part to your body tag.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9092
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Also right after html starts, right after the first head tag at the very top you have

Code: [ Select ]
</script>


Get rid of that, you shouldn't have that there.
  • fspigroup
  • Newbie
  • Newbie
  • fspigroup
  • Posts: 6
  • Loc: Manchester Uk

Post 3+ Months Ago

Yeh i have definatly placed both header and body tags in the right place, i just dont know why its not working.

DB
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9092
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Oh and I think I just seen where you put that body tag

Code: [ Select ]
<BODY OnLoad="checkCount()">


You put that on the bottom of your page. That is wrong. You need to add it to your current body tag which is towards the top of your page and simply add the OnLoad="checkCount()" to the end of it.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9092
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Also get rid of the following code at the bottom of your page:

Code: [ Select ]
<BODY onLoad="javascript:popUp('http://host.deluxnetwork.com/~antzoo/notice.html')">


You are only supposed to have one body tag in your whole document. You have like 3 of them.
  • fspigroup
  • Newbie
  • Newbie
  • fspigroup
  • Posts: 6
  • Loc: Manchester Uk

Post 3+ Months Ago

I would just like to thank you!

I finally got that cookie script working.

You also cleard up some line errors i was getting.

Thanks again.

DB :lol:

Post Information

  • Total Posts in this topic: 13 posts
  • Users browsing this forum: No registered users and 33 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.