Does anyone know a script in which a user can veiw a page one a day and if the user veiws it once more the text will change?
Does anyone know a script in which a user can veiw a page one a day and if the user veiws it once more the text will change?
For example: the page has a link that reads 'continue'. If the user veiws the page more than once on the same day, the text will change and say "Sorry you have already veiwed this page today, please return tomorrow."
Think you need to use cookies for that...
See if you can modify this script:
http://www.javascriptkit.com/script/...itorinfo.shtml
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
I'm not very good at editing scripts.... but thank you. Is there another possibility anyone?
There's nothing secure you can implement here. Even with a server-side script, you'd need to set up a login system and do it by that.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I think this will work... (Haven't tried it!)
Put it in the <BODY> tags.
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)); if(!(visit = GetCookie("visit"))) visit = 0; visit++; SetCookie("visit", visit, expdate, "/", null, false); var message; if(visit == 1) alert("Welcome!") if(visit>= 2) alert("You've been here too many times. Try again tommorrow.") //TO REDIRECT, DELETE THE "//" UNDER //window.location = "mypage.htm" //TO NOT CLOSE, DELETE THE NEXT TWO LINES UNDER window.opener = self window.close() } function ResetCounts() { var expdate = new Date(); expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); visit = 0; SetCookie("visit", visit, expdate , "/", null, false); history.go(0); } window.onload=DisplayInfo </Script>
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
That closes my browsers out...
![]()
I dont know but this is a second start:
HeHe!!Code:<html> <head> <title>Demo Box</title> <script language="javascript"> function ConfirmChoice() { answer = alert("Sorry, but you can only visit this page once a day. Try again tomorrow.") if (answer !=0) { location = "index.html" } } </script> </head> <body> <div align="center"><a href="#" onclick=" ConfirmChoice(); return false;">Try this!!! </a> </div> </body> </html>
Cookies are the only way without logins or some one-time-use security code or something.
However, the user can clear cookies.
Actually, though, there is a better way now that I think about it... use IP address.
In php, it's fairly easy... but you'd need to have serverside access. That's how you'd need to store the "used" IPs.
Now... note... there are obvious flaws with this... if someone refreshed, for example. but... do what you want.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
benslayton: What the heck is that code? :-\
window.alert() doesn't return a value.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks