Forum Moderators: phranque
On one site I would like to force visitors to read a message before allowing them to navigate to other parts of the site.
In this way if someone were to link to say index2.html they would be redirected to index.html then once they click a button after reading the message they are directed to index2.html
Any help would be appreciated!
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
createCookie('www.mysite.com','copyright',0)
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
var ck = name+"="+value+expires+"; path=/";
document.cookie = ck;
}
// -->
</script>
Now here is the tricky part, I put the following code in the second page (index2.html)...
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
go_to = "http://www.mysite.com/index.html";
function readCookie('www.mysite.com')
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
window.location = go_to;
}
// -->
</script>
What I want to do is if the cookie doesn't exist or is null then go to index.html otherwise just continue loading this web page. This script is not working.
Any help?
RewriteCond %{REQUEST_URI}!redirecter
RewriteRule (.*) [yourdomain.com...] [L]
That will redirect a request for <yourdomain.com/subpage.html> to <yourdomain.com/redirecter.cgi?subpage.html>
Your <redirecter.cgi> file is a Perl or PHP script that displays the log in page, with a link back to the page the user first tried to go to. It grabs the file for that page from the query string in the url.
I did something like this after the presidential election where anyone entering any page of my personal site was first shown a splash screen of a picture I commissioned of the statue of liberty holding a gun to her head.
I imagine jdMorgan will chime in here if I screwed the code up, if he checks out this forum....