Click here to Skip to main content
15,887,446 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to write an "IF" condition in html to redirect to index page "if" visitor is not coming from index page.
Posted
Updated 20-Jan-14 7:19am
v2
Comments
Kornfeld Eliyahu Peter 20-Jan-14 13:28pm    
Not clear...
IF is not part of html (that build on tags)! Do you mean JavaScript? Do you have a peace of code to show?
Member 10536511 20-Jan-14 14:24pm    
I want to redirect people to index page when they come from any other page outside our server...
Kornfeld Eliyahu Peter 20-Jan-14 14:26pm    
In that case see Solution 2...

You can use JavaScript[^] to do that:
HTML
<script type="text/javascript">
if (!document.referrer.endsWith('index.html'))
{
    window.location.replace('index.html');
}
</script>

Hope this helps.
 
Share this answer
 
v3
Comments
Karthik_Mahalingam 20-Jan-14 14:50pm    
5! good
Thomas Daniels 21-Jan-14 10:42am    
Thank you!
Well, first off, HTML is not a scripting language with functionality. You will need to use JavaScript, Classic ASP, or some other scripting language to accomplish this task.

It is pretty easy in Classic ASP. You can do exactly what you want. Just do some research.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900