Let popup once for event dialog or something like that in Javascript

CK CK 3788 
Created at  
425 0 0
If you have a popup window which opens on
your home page every time a visitor returns,it can become very
annoying. Using cookies,this script can determine if the visitor has
been here before,and only open a new window on their first visit to the
page. The next time they come back,the script will read the
cookie,identify them as a repeat visitor,and not open the window again.

onlyPopupOnce.js
var expDays = 1; // number of days the cookie should last

var page = "only-popup-once.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);
  }
}

window.onload=checkCount;


event_dialog.html
<html>
<head>
  <title>KURAPA.COM Event</title>
  <script type="text/javascript" src="onlyPopupOnce.js"></script>
</head>
<body>
.
.
.
</body>
</html>

Tags Cookie Form Cookies HTML Javascript Popup Blocking Popup Once cookieVal Facebook X
Comments 0
Similar posts
  1. New content notifier in Javascript
    597
  2. Save And Restore Form Cookies in Javascript
    334
  3. Cookie Redirect
    496
  4. Cookie enabled browser checking in Javascript
    342
  5. Access Granted
    586
  6. Greeting For The Time Of Day
    393
  7. Displays the number of pages that the users browser has displayed in its session
    666
  8. Address Book
    576
  9. Basic Date Display
    510
  10. How to record visitor's name by Cookie
    411
  11. Javascript implemented Calendar
    421
  12. Javascript based Alarm Clock
    666
  13. How to get date time in Javascript ?
    498
  14. Hiding HTML on the browser
    461
  15. Javascript & Cookie based Visitor Application
    435
  16. Getting WebSearchers On Your Site
    373
  17. Javascript Mouse Event Handler Example
    403
  18. Cross Browser Event Management Functions Using JavaScript
    611
  19. Select And Deselect All Checkboxes By Javascript
    632
  20. How To Read And Write A Cookie
    363
  21. Using C# With Cookies
    625
  22. Printing A Page
    378
  23. Example Of Creating Objects
    402
  24. Linking Drop Downs
    576
  25. Roman Numerals From Integers
    511
  26. Get A Print Dialog Box By Clicking A Button
    818
  27. Keyboard event detection (Key Tracker)
    1,087
  28. IsIn For Arrays
    568
  29. Confirm The Link Clicked
    630
  30. Enlarge Image
    514
  1. Javascript Mouse Event Handler Example
    403
  2. Getting WebSearchers On Your Site
    373
  3. Hiding HTML on the browser
    461
  4. jQuery and Function Chaining
    536
  5. How to get date time in Javascript ?
    498
  6. Javascript based Alarm Clock
    666
  7. Javascript implemented Calendar
    421
  8. Basic Date Display
    510
  9. Address Book
    576
  10. Displays the number of pages that the users browser has displayed in its session
    666
  11. Greeting For The Time Of Day
    393
  12. Access Granted
    586
  13. Cookie enabled browser checking in Javascript
    342
  14. Cookie Redirect
    496
  15. New content notifier in Javascript
    597
  16. Save And Restore Form Cookies in Javascript
    334
  17. How to record visitor's name by Cookie
    411
  18. Javascript & Cookie based Visitor Application
    435
  19. Cross Browser Event Management Functions Using JavaScript
    611
  20. Printing A Page
    378
  21. Example Of Creating Objects
    402
  22. Linking Drop Downs
    576
  23. Roman Numerals From Integers
    511
  24. Get A Print Dialog Box By Clicking A Button
    818
  25. Keyboard event detection (Key Tracker)
    1,087
  26. IsIn For Arrays
    568
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    39
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    34
  3. How do I create animated background for Google Meet?
    20,611
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    244
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    514
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    287
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    230
  16. TPU & GPU Cluster Management Tools
    243
  17. The Concept of Scaffolding in AI Agents
    233
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    258
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    221
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    220
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    195
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    216
  30. Understanding Data Lineage
    260