I FOUND A CODE ON THE JAVASCRIPT SOURCE THAT BLOCKS VISITORS FROM VIEWING A PAGE UNLESS THEY CAME FROM A CERTAIN PAGE. THE CODE WON'T WORK, EVEN WHEN ENTERING FROM THE CORRECT PAGE AN ALERT BOX SAYS YOU MUST ENTER FROM .... I AM USING THIS IN CONJUNCTION WITH A CODE I FOUND FOR PASSWORD PROTECTION. SO VISITORS HAVE TO LOGIN PRIOR TO VIEWING THE PAGE. HERE IS THE CODE.
Script LANGUAGE="JAVASCRIPT">
var requiredfrom ="login.html"; // required prev. page
if (document.referrer.indexOf(requiredfrom) == -1) {
alert("You must come to this page from " + requiredfrom);
window.location=requiredfrom;
} </Script>
THE SCRIPT IS VERY SIMPLE, BUT WHEN I TEST IN BROWSER, AFTER LOGING IN ON THE LOGIN PAGE (LOGIN.HTML) I GO TO THIS PAGE AND STILL GET THE ALERT SAYING YOU MUST ENTER FROM LOGIN.HTML. WHAT AM I DOING WRONG? THANK YOU FOR ANY HELP.
Script LANGUAGE="JAVASCRIPT">
var requiredfrom ="login.html"; // required prev. page
if (document.referrer.indexOf(requiredfrom) == -1) {
alert("You must come to this page from " + requiredfrom);
window.location=requiredfrom;
} </Script>
THE SCRIPT IS VERY SIMPLE, BUT WHEN I TEST IN BROWSER, AFTER LOGING IN ON THE LOGIN PAGE (LOGIN.HTML) I GO TO THIS PAGE AND STILL GET THE ALERT SAYING YOU MUST ENTER FROM LOGIN.HTML. WHAT AM I DOING WRONG? THANK YOU FOR ANY HELP.