PDA

View Full Version : Question about page loading...


Scke_Xival
03-14-2003, 10:18 PM
I dunno if this can be done with HTML or Javascript:

How can you make it so that a page can only be loaded by/from another page? Not by the direct addresss. Bascially only make it so that the visitor can not load the page by typing it into the address bar, but has to go through a specific page.

Thanks.

Borgtex
03-14-2003, 10:28 PM
use document.referrer

<script language="javascript" >
if (document.referrer!= "mypage.htm") {
...do that...
}
</script>

Graeme Hackston
03-15-2003, 07:10 AM
Just a warning, I read somewhere that Mozilla 1.3 has an option to alter the referrer.

Also, any browser can get past it with JS turned off. Maybe also include a meta refresh

<noscript>
<meta http-equiv="refresh" content="0;url=mypage.htm">
</noscript>

Although this wouldn't allow valid browsers with JS disabled to see the page. You'll have to decide

Scke_Xival
03-15-2003, 04:27 PM
thanks guys. thats exactly what i am looking for.

brothercake
03-15-2003, 04:56 PM
Originally posted by Graeme Hackston
Maybe also include a meta refresh

<noscript>
<meta http-equiv="refresh" content="0;url=mypage.htm">
</noscript>

Almost perfect ;) But that breaks the back-button; a small adjustment:

<meta http-equiv="refresh" content="2;url=mypage.htm">

Scke_Xival
03-15-2003, 05:03 PM
Originally posted by Borgtex
use document.referrer

<script language="javascript" >
if (document.referrer!= "mypage.htm") {
...do that...
}
</script>

I cant get this to work... What would I put for "...do that...". I tried using refresh command, but it doesnt seem to work

Borgtex
03-15-2003, 07:35 PM
Obviously, instead of ...do that... you must write the appropriate javascript code with the action to do: show a message, go to another page, etc.

Scke_Xival
03-15-2003, 07:42 PM
umm how would u make it show another page or go to? i don't know that much java script, only php and html

Scke_Xival
03-16-2003, 12:39 AM
umm how would u make it show another page or go to? i don't know that much java script, only php and html

Borgtex
03-16-2003, 10:42 AM
<script language="javascript" >
if (document.referrer!= "mypage.htm") {
self.location="errorpage.htm"
}
</script>