Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 07-17-2009, 07:45 AM   #1 (permalink)
Member
 
Join Date: 03-21-07
Posts: 30
iTrader: 0 / 0%
Latest Blog:
None

basketmen is liked by many
This little script make popup only appear once, but need little edit

Hi guys

below script is working to make popup only appear once in our website, but maybe its need some edit/fix



For example its working
first, user go to www.yourdomain.com/01/01/2009/title/ page -> then the popup appear
then the user go to www.yourdomain.com/01/01/2009/title/2.html page -> the popup NOT appear, so the script is working to make popup only appear once


but its not working if the user go to another path/folder, for example
first, user go to www.yourdomain.com/01/01/2009/title/ page -> then the popup appear
then the user go to www.yourdomain.com/01/01/2009/title2/ page -> the popup APPEAR AGAIN, so the script is not working if the path/folder different, still in same domain




this script is from here









Quote:
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +

((secure) ? "; secure" : "");
document.cookie = curCookie;
}

function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}

function pop()
{
theUrl = "http://www.yahoo.com";
window.open(theUrl,"theWindow","width=400,height=4 00,menubar=yes,toolbar=yes")
}

var seen = getCookie("seen");

if (!seen) {
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
setCookie("seen", 1, now);
pop();
}

//-->
</script>
</head>
<body>
blah
</body>
</html>





i had try removing the part in red above or only one of them, but its still appear if change to other path/folder, still in same domain, please help to fix it guys not appear again in entire yourdomain.com, whatever the path is

or if you have other script to make popup only appear once for each user, its good if you share it too guys
__________________
I like forum

Last edited by basketmen; 07-17-2009 at 08:00 AM..
basketmen is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-17-2009, 12:53 PM   #2 (permalink)
Moderator
 
Hades's Avatar
 
Join Date: 01-23-07
Location: Buenos Aires, Argentina
Posts: 1,259
iTrader: 0 / 0%
Hades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest order
I would suggest commenting/removing the line:
Code:
((path) ? "; path=" + path : "") +
that way your script will ignore the whole path thing and it will work all across your domain.

However that script will fail to open popups in most of the cases because every new browser comes with a popup blocker. You should look into javascript floating windows, or javascript modal messages.

Regards,
__________________
Hades,
Ancient god, King of the Nether World, and Guardian of the Dead.
...and on my free time I'm also a web developer, contact me if you need one!
Hades is online now  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make this URL Popup Work? HowtoFactor Coding Forum 1 07-12-2009 10:08 AM
Make The User Experience Good To Avoid Hand Edit peter_d SEO Forum 5 10-11-2007 10:13 AM
I am having a popup script code which I want to extract it and put it on other file b poseidon Coding Forum 9 10-08-2007 09:05 PM
Anyone knows a easy script for a image popup? crazyhorse Coding Forum 5 07-31-2004 02:25 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:17 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.