SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Aug 9, 2000, 17:49 #1
- Join Date
- Jun 2000
- Location
- Newnan,Georgia,USA
- Posts
- 22
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I was wondering if any you of you guys know of a code (if one exists) that lets you have a pop-up window that can have like buttons that allow the person to choose :
"Close this window forever"
"Or don't ask me again"
and when they click that they pop-up closes and never shows up again for that person.
-
Aug 10, 2000, 00:07 #2
You would have to use a cookie, and have the box read the cookie, if it wasnt there, it would popup, and if the cookie was there it wouldnt popup the box
-
Aug 18, 2000, 16:29 #3
- Join Date
- May 2000
- Location
- On some harddisk
- Posts
- 599
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yeah, that's it but what he needs is the code ....
-
Aug 19, 2000, 18:24 #4
- Join Date
- Sep 1999
- Posts
- 1,390
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I can't help with the code, but cookies won't keep the window from ever popping up on EVERYONE's computer. People with cookies disabled or an old browser will get the popup forever.
------------------
Aidan Bahta
abahta@activewm.com
ActiveWM.com - The place for the Active Webmaster.
-
Aug 28, 2000, 02:49 #5
yes, thats true, there is no way to make the popup box never showup again. And I cant help you with the cookie code myself, I am still learning cookies as well. Sorry that I couldnt be of any more help
-
Aug 28, 2000, 11:22 #6
- Join Date
- Feb 2000
- Location
- NE FL, USA
- Posts
- 301
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this
Code:<SCRIPT LANGUAGE="JavaScript"> function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } 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 = (2 < argc) ? argv[2] : null; var path = (3 < argc) ? argv[3] : null; var domain = (4 < argc) ? argv[4] : null; var secure = (5 < argc) ? 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 DisplayInfo() { var expdate = new Date(); var visit; expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); if(!(visit = GetCookie("visit"))) visit = 0; visit++; SetCookie("visit", visit, expdate, "/", ".your-domain-name.com", false); var message; if(visit == 1) popup() } /////////////editable part/////////////////////////////////////// function popup(){ window.open('http://www.your-domain-name.com/popup.html','win1','width=550,height=440,resizable') } /////////////editable part/////////////////////////////////////// </script>
1.) Paste between the head tags on every page that you want it to pop-up when that page is left.
2.) Change the URL (highlighted in red) of the pop up to the location of it on your site.
3.) Put: OnUnload="DisplayInfo() at the very end of the BODY tag on every page that you use the JavaScript on. This is what it looks like in my BODY tag: <body bgcolor="#FFFFFF" OnUnload="DisplayInfo()">
3.) Fiddle around with the width and height settings (highlighted in green) to make sure that the window that opens isn't too big or too small. Temporarily disable cookies while testing the script in order to see the pop-up every time.
4.) Change your-domain-name.com to your actual domain. If you are hosted by a free web space provider like geocities.com, use your directory there. For example you would replace .your-domain-name.com with .yourisp.com/mysite/ -- notice the period in front of the domain.
5.) Upload the file. You're done.
On the page that you have pop up, just add the following:Code:<p>No thanks, <a href="javascript: self.close()">close this window</a>.</p>
MikeBrain Bucket Magazine - Biker News, Views, and Event Coverage.
Bookmarks