/    Sign up×
Community /Pin to ProfileBookmark

I need a code plaese.

i need a code that when you visit a page, you can. when you try to refresh, or leave and come back later, you get a message saying you must wait 24 hours to come again. so once you hit refresh or leave, the time (24 hours) begins. Could someone make that at all?

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@pcthugMay 14.2006 — The only way JavaScript can do this is by setting a cookie. The alternative method is to use server-side scripting to disallow that ip for 24 hours
Copy linkTweet thisAlerts:
@metroid87706authorMay 14.2006 — can I have the cookie version?

i doubt anyone on my site will know that it sets a cookie.

Btw, when they restart the browser or system, will it still be there?
Copy linkTweet thisAlerts:
@netbuddyMay 14.2006 — Why do you want to limit a user to visiting the page once in 24 hours??? what if the page does not load properly first time around??? How are people to refresh the browser to make the page display correctly...

Cookies can be deleted, so this would be pretty weak solution to limiting a persons visit, also if its by IP address, your system will not account for IP address changes, again another weakness in your plan.

In all seriousness, you want to re-think your plan on limiting visitors, afterall, the aim of the game is to get as many visitors to your site and not hinder them...
Copy linkTweet thisAlerts:
@metroid87706authorMay 14.2006 — because I have an acccount on imvu, AN IMSTANT MESSANGING SITE, AND I HAVE AN ARCADE WHERE YOU EARN CREDITS (mONEY IN imvu) AND i WANT PEOPLE TO PLAY EACH GAME ONLY ONCE A DAY. (SRy caps)
Copy linkTweet thisAlerts:
@metroid87706authorMay 14.2006 — i dont care if they can delete them. most people dont know how and what they even are.

And if it doesnt work, oops. Guess u can skip the game for the day
Copy linkTweet thisAlerts:
@kiwibritMay 14.2006 — Hmm, you don't have a public privacy policy then. Watch you are not [url=http://www.out-law.com/page-1240]breaking the law[/url] where you are.
Copy linkTweet thisAlerts:
@metroid87706authorMay 14.2006 — Im not. I know im not, and it tells them that they cant do it for another 24 hours and such.

So, anyone got a code for me?
Copy linkTweet thisAlerts:
@metroid87706authorMay 14.2006 — can anyone get the code 4 me? I need it like, really badly, and very soon.
Copy linkTweet thisAlerts:
@gooncorpMay 16.2006 — put this in your head section:


<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 fixDate(date) {

var base = new Date(0);

var skew = base.getTime();

if (skew > 0)

date.setTime(date.getTime() - skew);

}

// -->

</script>


and then put this at the top of the body section, ideally it should be the first thing on the page:


<script type="text/javascript">

<!--

var now = new Date();

fixDate(now);

now.setTime(now.getTime() + 24 * 60 * 60 * 1000);

var visits = getCookie("counter");

if (!visits) {

visits = 1;

alert("welcome to the page")

setCookie("counter", visits, now);

} else {

visits = parseInt(visits) + 1;

if(history.length > 0){

alert("less o' yer cheating, ye scumbag!!!")

history.go(-1)

}else{

alert("less o' yer cheating, ye scumbag!!!")

window.location="http://www.google.com"

}

}

// -->

</script>


Although you could have done this yourself, I got most of this code of other websites and just tweaked it a bit.
Copy linkTweet thisAlerts:
@gooncorpMay 16.2006 — Oh, and you can get around this by clearing your cookies, and it won't allow you to refresh the page if it doesn't load properly. You might want to change the alerts as well if you want your visitors to come back to your page.
×

Success!

Help @metroid87706 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.18,
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,
)...