Is there any javascript code available that will allow a page to display only when there is additional text added to the url? I tried using a password protect code but it did not work.
Is there any javascript code available that will allow a page to display only when there is additional text added to the url? I tried using a password protect code but it did not work.
Note that it doesn't actually offer any additional security at all.Code:<script type="text/javascript"> if(window.location.href.indexOf("?redcrestedwarbler") == -1 && window.location.href.indexOf("&redcrestedwarbler") == -1) window.location.replace("http://www.google.com/"); </script>
Last edited by Twey; 03-27-2006 at 08:57 PM.
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!
redcrestedwarbler?
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
I think it's a rare bird. I just scraped it off the wall.![]()
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 guess my question was - Won't that be almost as good as hard coded link to Google?
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
It's one line of Javascript... hardly "hard-coded"
techsol: Change the bits in red, if you didn't figure that out alreadyCode:<script type="text/javascript"> var keyword = "redcrestedwarbler", // Keyword badurl = "http://www.google.com/"; // Page to go to on failure if(window.location.href.indexOf("?" + keyword) == -1 && window.location.href.indexOf("&" + keyword) == -1) window.location.replace(badurl); </script>![]()
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 was thinking more along the lines of testing for any appended characters via a regex. Mike and you are probably better at this than I but isn't there a token for any letter and one for any number? Just check against a 'one or more occurrences' of either and you've got it.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
I sort of got the impression the OP wanted a specific string.Originally Posted by John
\d for a digit, or [a-zA-Z] for a letter. But I don't think that's what was wanted here.isn't there a token for any letter and one for any number?
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 put the code into my page and replaced the items in red. I tried to get to the correct page by putting this url in my browser: http://www.mysite.com?keyword="redcrestedwarbler" where www.mysite.com is the protected page on my site and "redcrestedwarbler" would be the keyword but I could not get it to work.
What am I doing wrong? I am not javascript savvy…thanks
I finally figured it out. You have to add ?keyword to the end of the page url. Is there any way to write the code such that the keyword would disappear from the URL when the correct page is selected. When I add this to the end of my page url it goes to the right page but the ?keyword appears in the URl.
Bookmarks