Click to See Complete Forum and Search --> : Referrer script assistanace pleeaase


Drew Peacock
08-13-2003, 11:34 AM
Hi!
Can someone please tell me why this script isn't working for me?
I'd really, reeaally appreciate it. I'm running out of hair to pull out! :p



<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var requiredfrom = "home.htm"; // required prev. page
if (document.referrer.indexOf(requiredfrom) == -1) {
alert("Wrong door!");
window.location=requiredfrom;
}
// End -->
</script>

Oh, and yes it's in the <head> of my html document. I'm still a noob at this though.
Thanx.

Khalid Ali
08-13-2003, 11:50 AM
document.referrer is web server dependat.Therefore if the server does not put this info in the HTML header you won't be able to retrieve it...???
does that answer your question..:-)

Drew Peacock
08-16-2003, 09:58 PM
does that answer your question..:-)
Hmmm, kinda. Thanx for letting me know where I'm going wrong (actually, I didn't write the script but you know what I mean).....

OK, here's the deal:
Many people are stealing my webpages and posting them in tacky forums. I'm using freehosts so when this happens the bandwidth spikes and I lose the account.
So I'm trying to put a referrer script on my pages but 90% of internet users surf with java disabled, thus rendering the script inactive. That's when I decided to put a java password protection script on my pages to force the users to enable java, then the referrer script will work.

Can somebody pleeaase help me.
Is there another way to prevent people from seeing my pages if they have java disabled (to replace the password script)? Is there a referrer script written in plain html? How do I get two scripts to work on the same page? Am I asking too many questions? Should I give up now before I lose my marbles?

Huge thanx for reading my dilemma. Mega humungous thanx for any assistance! :) :) :) :)

xataku_nakusute
08-17-2003, 03:30 AM
well....i know theres a way to detect certain browser plug-ins...however, whther or not the browser has javascript enabled, im unsure of.

i was just reading that for links, you can do this to filter out those people:

<a href="non-js.html" onclick="window.location='js-enabled.html'; return false">Filter Em Out!</a>

however, as you can see, this is only for links....
also, if you want, you can encrypt your pages codes....
in fact, i have the encrypter page right here.
all you have to do is enter your source code into the textarea within the provided html doc and then press 'Encrypt'.
to decrypt it again, just press 'Source'. this page can be run from your desktop so the i-net thieves cant take your encryptor and figure out how to break the code.
one end not as well:
i suggest you to instead of making pages that contain all of your info: css, javascript, html, etc....make pages that are linked to your css files and your .js files. that boosts your security a bit more. and unless you do so already, i really think you should do so.

also, the encryptor CANNOT encrypt your css or javascript. it can only encrypt any html you have. it does so by converting every <, >, ", ', etc...into a browser-compatible character entity, eg:
< becomes %3C when you view the source.

i hope this helps!

EDIT:
you can also make a page thats made for all browsers and make this your coding:

<html>
<body onload="document.location='js_enabled_page.html'">
</body>
</html>
that way, people with javascript enabled can go to your main site, and those who do not cannot without finding out the sites main location. and btw, the encryptor is included in my next post

xataku_nakusute
08-17-2003, 03:54 AM
here you go:

Drew Peacock
08-17-2003, 05:17 AM
Thank you very, very, very..... much for coming to my aid but to be perfectly honest you may as well have written that in Japanese! Sorry, but I'm a noob at this script writing stuff.
I understand that encrypting my documents is a good idea for added security, thanx for that little program.

But I just found this script which detects if users have java enabled, and redirects them if they haven't:
<!--
// == Begin Redirect Code Provided By www.DesignerWiz.com ==
--><!-- Begin
if (navigator.javaEnabled())
window.location = "java_enabled_redirect.html";
else
window.location = "nojava.html";
// End -->
</script>
My only question, at this point, is: can I use two different javascripts in the same header of the same document?
If so, do I need to combine them into one script (ie. remove the 'begin' and 'end' tags) or can I simply paste them one after the other?

Thanx.

xataku_nakusute
08-17-2003, 05:39 AM
oh, forgive me for that.
now, on to your question:
yes, you can write more than one script in the <head> section, and also, it doesnt matter whether or not they are within the same <script</script> tags or not.

<script>
blah
blah2
</script>

is the same as

<script>
blah
</script>
<script>
blah2
</script>

however, to add more security, i would suggest you link your page to an external .js file.

this is how you do it:

first, take your scripts and strip them entirely of their <script> and </script> tags.
save the remaining text into a new txt document and save it as "my_scripts.js".
now, in the <head> section of your html page that you need those scripts for, type:
<script type="text/javascript" src="path/to/my_scripts.js" />

and that simply calls your scripts from another file so if someone wants to take your scripts, theyd have to first, find your .js file, and then download it and take the scripts and then recode them.

now, for your second question:

the beginning and end "tags" are simply just operators that make it so that older browsers do not parse(read) the contained code.
so:
<!--begin
...scripts...
// end --!>
in this code, the scripts within will not be parsed(read) by users with browsers such as NS3 or MSIE2 or whatever.

so, to conclude, it is up to you whether or not you put your other codes within those tags or not.

i hope i explained everything a bit better this time