Click to See Complete Forum and Search --> : Need help new problem age verification sript
Macman
08-31-2003, 04:17 AM
Have script which works perfectly in IE 5.1.7 for Mac. It does not work at all in Netscape 4.8, but woks sort of in Mozilla. Can anyone tell me if there is a way to have the attached script work in Netscape?
In addition I want to know if I can set a IP cookie when a surfer is blocked because they are under 18 yrs. Then if they try again from the same IP putting a birthdate that would make them older than 18, have them redirected away from the site with a redirect script which I have.:confused:
Use this: document.FormName.SelectName.options[document.FormName.SelectName.selectedIndex].value
to get the value of your variables.
Saving the cookie is not a problem, neither is deleting it!
Macman
08-31-2003, 01:00 PM
Jang
I don't understand where that line of code goes. Do I include that with the current script between the head tags?
My problem is that the script does work fine in IE browser but does not block surfer in Netscape. Assuming that they have javasript turned on.:confused:
David Harrison
08-31-2003, 01:18 PM
He means don't use document.getElementById, I used it because I think it's easier and anyone using browsers that don't support it should download a better, NEWER, browser. Any way, see if this fares any better:
lavalamp sorted that for you, note the name replacing id in the form.
Run your code through a validator; nesting errors, missing end tags, entities not correct ...
The variable year returns 103 instead of 2003 in some browsers (old & new), the fix is quite easy.
David Harrison
08-31-2003, 01:56 PM
I thought I had replced all of the id's (that mattered) with name's. I didn't think of the year thing though, beter add this then:
year+=(year<2000)?1900:0;
I must point out though that I didn't write the HTML for that, I just changed the script. I make a point not to touch any of the code that I don't have to, although if its very bad I might point it out to them. If you wanna take a look at some of my code, just check out my www (http://www.geocities.com/caulolli/).
lavalamp I was pointing out the id changes to Macman :D
David Harrison
08-31-2003, 02:10 PM
Oh sorry, when you said, "lavalamp", I thought you were talking to me.
Re-uploaded the attachment with the year fix in, ignore the last one.
Macman
08-31-2003, 08:04 PM
Lavalamp that last script works perfectly in IE, Monzilla and in Netscape 7.01. It is apparent that it will not work in Netscape 4.8. I am going to make a very big assumption that those surfers still using 4.8 are a very small minority although I will have to check that in my server or counter stats to see if that is true.
Now I dug through all my scripts looking for the last piece of the puzzule so to speak. In the file I am attaching is the html page with the javascript that works. At the very top I pasted two cookie scripts. The first sets a cookie which I would like it to do only if the surfer was underage. It should persist for a period of 4320 hrs. or 6 moonths. It only needs date and IP address. Now the second script is a redirect which if it sees the cookie will prevent the surfer from entering the site even if they enter a new birth date that makes them over 18. That script then sends them to yahoo or where ever. I would appreciate a look by both you and Fang as I want to thank him for his comment about the id changes which I caught and understood when I took another look. You did a great job on this script. May I suggest Lavalamp that you submit it to JavaScript Source (http://javascript.internet.com/). You did bulk of the hard work.:)
Macman
09-01-2003, 03:02 AM
I spent most of the day reading through some books and surfing various sites for a script that would detect a surfers browser and if it was not Nenscape 6.0 or higher IE 5 or higher and javascript not enabled then on load they would be sent to www.yahoo.com etc. Since they would be able to bypass the age veridication script. Any ideas would be welcomed I want to pulg that loophole also.:rolleyes:
Here's a list you might want to check:
Generated by CSE HTML Validator Lite v3.50 (http://www.htmlvalidator.com/)
1. Error in line 83 at character -1: Found the character '<' while looking for '>'. The character '>' must appear before another '<'. If you actually want to use this character in the text portion of your document, you should use the character entity "<".
2. Error in line 83 at character -1: Found an ampersand '&' but could not find a following semicolon for a properly formed character entity. If you want to actually display an ampersand, such as in "Recreation & Sports", then you should use the character entity "&" as in "Recreation & Sports" (see comment).
3. Error in line 83 at character 5: The closing tag for "font" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
4. Error in line 227 at character -1: Found an ampersand '&' but could not find a following semicolon for a properly formed character entity. If you want to actually display an ampersand, such as in "Recreation & Sports", then you should use the character entity "&" as in "Recreation & Sports" (see comment).
5. Error in line 233 at character 2: The closing tag for "b" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
6. Error in line 233 at character 5: The closing tag for "font" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
7. Error in line 233 at character 3: The closing tag for "td" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
8. Error in line 233 at character 3: The closing tag for "tr" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
9. Error in line 233 at character 6: The closing tag for "table" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
10. Error in line 233 at character 3: The closing tag for "td" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
11. Error in line 234 at character 3: The closing tag for "tr" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
12. Error in line 234 at character 6: The closing tag for "table" was found, but the tag was never opened, has been closed too many times, or cannot have an end tag.
13. Comment: The ampersand '&' is an escape character in HTML. If you want to actually use the ampersand in your HTML document, you should use the character entity '&' instead of the actual ampersand character by itself.
Sux0rZh@jc0rz
09-01-2003, 03:47 AM
any teenager worth his salt would know to get passed that to delte the cookie or turn off cookies. (14 year old here so I know what I'm talking about=P)
Also: I have JS enabled but I have cookies turned off so that script wouldn't do anything to keep me from getting in. just use credit card verification to keep kids out. its a lot easier.
EDIT: also, you'd be cutting out those adults who have those browsers and netscape is a minority but its still a big one. Just keep trying to find a script that works with netscape too.
Sux0rZh@jc0rz
09-01-2003, 03:54 AM
Heres a code you could work with. You could put it on your main page or something before they get to the form about their age this way they never even see the form if they are using netscape.
<script type="text/javascript">
function redirectme()
{
bname=navigator.appName
if (bname.indexOf("Netscape")!=-1)
{
window.location="tryjs_netscape.htm"
return
}
if (bname.indexOf("Microsoft")!=-1)
{
window.location="tryjs_microsoft.htm"
return
}
window.location="tryjs_other.htm"
}
</script>
<body>
<form>
<input type="button" onclick="redirectme()" value="Redirect">
</form>
</body>
Hope this helps:)
It runs ok in Netscape 4, 4.5, 6.2 and 7. The problem appears to be with 4.8 Anyone with 4.8?
Sux0rZh@jc0rz
09-01-2003, 04:10 AM
what, my script or his?
David Harrison
09-01-2003, 11:41 AM
May I suggest a slight adjustment to Sux0rZh@jc0rz's script:
<script type="text/javascript">
function redirectme()
{
bname=navigator.appName
if (bname.indexOf("Netscape")!=-1)
{
window.location="tryjs_netscape.htm"
return
}
if (bname.indexOf("Microsoft")!=-1)
{
window.location="tryjs_microsoft.htm"
return
}
window.location="tryjs_other.htm"
}
</script>
I don't know if it would make any difference but I personally would do this:
<script type="text/javascript"><!--
function redirectme(){
bname=navigator.appName;
if(bname.toLowerCase().indexOf("i")>=0 && bname.toLowerCase().indexOf("e")>=0){location.href="tryjs_ie.htm";}
else{location.href="tryjs_other.htm";}
}
//--></script>
I can try that script with Netscape 4.79 but that's the closest I've got. I'm sorry but I can't help you right now Macman, I'm in an Internet Café and I can't stand this keyboard.
David Harrison
09-01-2003, 05:10 PM
OK, version 4. So what's new? Well:
* I found a bug with the age calculation bit so I fixed it.
* Now it creates a cookie if the user is underage which lasts for 6 months. No extra functions added for this by the way, just one line of code.
* It also tries to detect the cookie and if it finds it, it redirects them to Yahoo.
As of yet there is no browser detection as I don't have the time and I'm not sure which browsers do support cookies and which don't.
Macman
09-02-2003, 01:05 PM
The script looks great and I believe it will pass muster. Still have one thing I want to do. If surfer does not have cookies enabled and javascript enabled I want them to be redirected to another page. The page will simply explain that they must have those enabled to view the site. It has to be timed so that they can not go back to the site and maybe a meta tag refresh or redirect would take them to say Yahoo. The idea is if they don't have those enabled they can't stay on the site. Any ideas will be welcomed and appreciated.:)
David Harrison
09-02-2003, 01:14 PM
For the redirect page it would be easier to redirect the people with javascript and cookies, rather than those without. The page may look a little like this:
<html><head><title>Check Page</title>
<script type="text/javascript"><!--
if(document.cookies){location.href="wherever.html";}
//--></script>
</head><body>
<script type="text/javascript"><!--
document.write("You have JavaScript enabled but not cookies.");
//--><script>
<noscript>
You don't have JavaScript enabled.
</noscript>
</body></html>
Macman
09-04-2003, 04:41 AM
I have attched a final working set of a two page age Verification form check box script and a index.html splash page which is the redirect for now compiant browser's. It works primarily in IE 5x and Netscape4x except for 4.8. I will be glad to answer questions on its use. Send me an email or private message. Thanks for all the help.:)
Macman
09-06-2003, 02:43 AM
Finally finished checking the script I posted above. Found two problems. First this script primarily works in Netscape 6.x and IE 5.x. I did not check any older IE versions and only checked Netscape 4.79 and 4.8 which it does not allow surfer to go any further. Netscape 6.0 and higher has no problem. I believe some other members have pointed out the the older browsers do present problems with the use of javasript. Since I use a large amount of javascript on my web site's pages I felt that indicating that would provide a reason for the surfer to upgrade to a more current browser. Since you can download for free the latest Netscape and Internet Explorer browser why not do so. The change from what I posted is the following: on the index page in the <body> use this instead of what I originally had.
<noscript>
<b><font face "Arial" size=+4>You do not have JavaScript enabled.<br><font size=+1> open preferences in the edit menu in Netscape turn on JavaScript. In Internet Explorer open preferences, click on Web content, at bottom in Active content click all three check boxes.</b></font>
</noscript>
This prompts users that have disabled cookies and javascript to activate them to enter the site. Feel free to snd me a message in regard to this whole script.:)
David Harrison
09-06-2003, 11:33 AM
Happy to help. :)