/    Sign up×
Community /Pin to ProfileBookmark

Need help. Newbie.

Im working on a popup add that popup after 8 seconds after my index page loaded.

<script language=”javascript”>

setTimeout(“window.open(‘http://myad.com’,”,’toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=450,top=50,left=50′)”,8000);

</script>

The problem is it pops up in all pages of my website.

I only want it to pop up once at the index page.

How do I do that?
?

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@TcobbOct 22.2010 — Only include the code for the page index.html.
Copy linkTweet thisAlerts:
@MaztaPaoauthorOct 23.2010 — Oh yes, how can I miss that. :o

Thanks Man.

but the thing is, i only want it to pop up once.

Cause if I go back to index page after I went to another page,

its popping up again.
Copy linkTweet thisAlerts:
@TcobbOct 23.2010 — About the only way you can do this is to use a cookie, probably one with a short life.

1. Check for the cookie onload

2. if one isn't there, set one on the browser and have your "popup" pop up.

3. If the cookie is there, don't have it pop up.

--Of course, this does assume that the visitor will have both javascript and cookies enabled on their browser.
Copy linkTweet thisAlerts:
@Christophe27Oct 23.2010 — Popups are annoying, except when the user specifically asks for it to pop open (after a button click for example) and popups reduces the number of returning visitors. After all, you want people to visit your website, right? I always click away when a website has popups and will never link to them! This seems a little cruel, but it really doesn't add any value to your website, on the contrary!

Please think twice before using pop-ups on your website.

Christophe
Copy linkTweet thisAlerts:
@MaztaPaoauthorOct 25.2010 — Thanks for the advice Christophe27?



I will look into that Tcobb. Many thanks.


I'll just post again if I have problems.
Copy linkTweet thisAlerts:
@Christophe27Oct 25.2010 — You're welcome! ?
Copy linkTweet thisAlerts:
@MaztaPaoauthorNov 12.2010 — I found a script for the cookies and it work very good.

http://javascript.internet.com/cookies/only-popup-once.html

It set to delete the cookies after a day.

how can I change this to delete within 6 hours?

I tried to change the variable to hours but I got an error: expDays not define.
<i>
</i>var expHours = 6;

and the function:

function DeleteCookie (name) {
var exp = new Date();
var hours = Time.getHours();
exp.setTime (exp.getTime() - 6);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

Did I do right?
Copy linkTweet thisAlerts:
@WolfShadeNov 12.2010 — Set the cookie to expire in six hours, you don't have to create a function for deleting cookies.

And I agree about how annoying pop ups are. If a site becomes too persistent with them, I avoid them. Not to mention, considering how many people use pop up blockers, there's a chance that your pop up isn't even being seen. Better to put that information in a corner of the website where people can still see it and won't be bothered by a pop up. Just MHO.

^_^
Copy linkTweet thisAlerts:
@MaztaPaoauthorNov 12.2010 — Sorry for being stupid but, how do I do that?:o

Just the var?

var expHour = 1;

but I got the same error message: expDay not defined.
Copy linkTweet thisAlerts:
@TcobbNov 12.2010 — I don't know what your cookie-creating function looks like or what parameters it takes. I assume that it requires, at least, the name of the cookie, the string content, and the expiration date (usually as a number of days). Try putting 0.25 for the number of days to expire. See if that works. It is also the case (which may be more in line with what you are looking for) that if no expiration date is specified the cookie dies when the user closes the browser.
Copy linkTweet thisAlerts:
@MaztaPaoauthorNov 14.2010 — I think it is working now.

I only changed the variables:

var [B]expHours = 6[/B];

var exp = new Date();

exp.setTime(exp.getTime() + ([B]expHours[/B]*24*60*60*1000));


May I know what this "(expHours*24*60*60*1000));" say?

The 24*60*60*1000?
Copy linkTweet thisAlerts:
@MaztaPaoauthorNov 16.2010 — Cookies does not save in Google Chrome.

Even though I "allow all date to be set" , in Content Settings under Cookies.

Popup appears on all pages in Google chrome.

Any ideas mon??
×

Success!

Help @MaztaPao spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...