/    Sign up×
Community /Pin to ProfileBookmark

JavaScript Pop Up

I’ve been working on creating a pop up for a candy fundraising website, and have come across one JavaScript code question that’s been really bugging me.

The code is as follows (in the <head>):
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval(“page” + id + ” = window.open(URL, ‘” + id + “‘, ‘toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300,left = 690,top = 190’);”);
}
// End –>
</script>

Is there any code that I’m missing that would tell the pop-up to load only the first time a user opens the site? Every time the main frame is opened, the pop-up (of course) pops up. However, it’s distracting to have it open every single time a user refreshes, etc. How would I go about having this pop-up only open once for a user?

Thank you for any help you can give me! It’s much appreciated.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ray326Jan 04.2004 — The only way I know of doing that is to set and test for a cookie with an appropriate (for your application) expiration date.
Copy linkTweet thisAlerts:
@Reb80authorJan 06.2004 — Wow, I would have no idea how to even think about doing that. lol

I was hoping there would be some kinda of value I could change in the code to open the pop up once... but the more I think about it the more I realize it's going to be very complicated, and I'm not very experienced in JavaScript coding.

Thank you for your reply, though! ?
×

Success!

Help @Reb80 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...