master maste
New Member
- Reaction score
- 32
I'm just playing around with some websites on my localhost, and I was wondering how I could have 'http://localhost/wordpress/?p=1' show content based on the referrer. Preferably using Javascript.
So if the person reaches 'http://localhost/wordpress/?p=1' from 'http://localhost/wordpress/?p=2' then it will show my content, otherwise if it comes from anywhere else it will display a message saying page is not available.
This should be able to work on the same page without redirecting to 404's or other articles right?
Heres some code I've been messing around with:
Should this code do what I want it to?
Thanks guys
edit: how would I deal with people who have javascript disabled? could I also automatically redirect them to a 404 page if they don't have javascript enabled. Or better yet display a message on that page which tells them to enable javascript to continue.
So if the person reaches 'http://localhost/wordpress/?p=1' from 'http://localhost/wordpress/?p=2' then it will show my content, otherwise if it comes from anywhere else it will display a message saying page is not available.
This should be able to work on the same page without redirecting to 404's or other articles right?
Heres some code I've been messing around with:
Code:
<script language="JavaScript"><!--
if (document.referrer.indexOf('http://localhost/wordpress/?p=2') > -1)
document.write('This is the page you can see.');
else
document.write('sorry this is not available to you at this time');
//-->
</script>
Should this code do what I want it to?
Thanks guys
edit: how would I deal with people who have javascript disabled? could I also automatically redirect them to a 404 page if they don't have javascript enabled. Or better yet display a message on that page which tells them to enable javascript to continue.