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 1522 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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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.
...
|
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,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
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...
|
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...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |