Hi
i have a popup which appears once when the page is opened and then the cookie is deleted on the no of days mentioned, but here i need to change it on the session basis, i;e when the page is closed event the cookie as to be deleted. Below is what the code i have been using. Please help me out on this.
Thanking You,
Regards,
Shiv. - var expDays = 1; // number of days the cookie should last
-
-
var page = "Popup.html";
-
var windowprops = "width=345,height=335,location=no,left=180,top=300,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;
1 1526 acoder 16,027
Recognized Expert Moderator MVP
Call DeleteCookie() onunload.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: David Graham |
last post by:
Hi
I use an OnLoad event in the body tag to open a popup window. I would like
to know how to go about only allowing the window to popup once i.e on
subsequent visits to the parent page, the popup np longer pops up. I think
it is irritating to users to have to close the popup everytime they visit
the page. I think I need to set a cookie so that the server knows the
visitor is a return visitor and not a new visitor, but I have no idea how to...
|
by: Dan |
last post by:
First, I'm sorry if this question has been asked
too many times. I'm new to this news group.
The question has to do with the use of popup
windows in a web page. I have heard that popup
windows should be avoided; due to use of popup
blockers and browser that do not process javascript.
Is the use of popup windows bad design?
Will it severly reduce the usage of our web page?
|
by: Davey |
last post by:
I have a website which has a popup window (this only opens when the user
chooses to open it). In the popup window I have a <select> control which
lists a selection of "classes". Each class has a description and a class_id
(stored in the value attribute of each option). The user will then select a
class from the drop-down list.
What I want to do is have a control in the parent browser window which can
store the class_id and the...
|
by: H00ner |
last post by:
Hello All
Hope you can help
Been pulling my hair out about a popup problem in ASP.NET. One of the
forms i wrote requires the user to select a product from a list in a
popup web form. the popup has a DataGrid on it and the page.load
function DataBinds as you'd expect.
I have Code-Behind in C# to emit a call to a JavaScript function which
|
by: ukrbend |
last post by:
I use an iframe on my home page and everything works perfectly. But
now I decided to add a popups to my page. The popups come not from
within the iframe but from the parent frame. Again, everything
regarding the popup works perfectly, it pops up with the correct data.
But the strange thing is now any link that targets the iframe simply
get ignored and instead of displaying things in the iframe they get
displayed in a new browser window...
| |
by: wreed06 |
last post by:
Hello,
I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully validated my HTML and CSS code.
1. When I clear cache and refresh my webpage, it takes 3 tries before the popup window displays - I click on the button once, a white window the size of my webpage displays. I close it and click on the button again (for...
|
by: wreed06 |
last post by:
I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully validated my HTML and CSS code.
1. When I clear cache and refresh my webpage, it takes 3 tries before the popup window displays - I click on the button once, a white window the size of my webpage displays. I close it and click on the button again (for the same...
|
by: =?Utf-8?B?U3VyZXNoIFJlZGR5?= |
last post by:
I am getting a strange problem with IE7 tabs.
The web application I am working (developed in ASP.Net, .Net 2.0), will show
a popup message with the count down timer 2 minutes before session time out.
The count down timer on popup will start with 120 and will be count down to 0
and if the user doesn't click on the Continue button (which is on popup),
application logs out and the web page will be shown with login page. If the
user clicks...
|
by: V S Rawat |
last post by:
using Javascript, I am opening a web-based url in a popup window.
MyWin1=Window.Open(url, "mywindow")
There is a form (form1) in the url in that popup window, I need to
submit that form.
How do I submit that form1 from the javascript from my current window?
Thanks.
|
by: Bruce |
last post by:
I have an application where a main window opens a popup window. Within
the popup, I want to be able to post a form back to the popup all the
while maintaining the opener property.
Of course, once the popup window re-loads itself by posting a form to
itself, all Javascript state information is lost and so opener is
undefined.
Is there any way I can communicate with the original opener of a popup
window once the popup window has been...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |