This code was previously used to prevent the page from using the IFRAME
Copy Code code as follows:
<script type= "text/javascript>
if (top.location!== self.location) {
Top.location=self.location;
}
</script>
But in Firefox you will find that the page will be constantly in the brush. The page doesn't work at all.
Here is because the Firefox windows.top if not so is empty, under IE windows.top is this window page constantly refresh the running of this section of JS code This creates a dead loop, is why the page has been refreshed.
So I changed the way that the following code is compatible with Firefox
Copy Code code as follows:
<script type= "text/javascript>
if (window!=parent)
Parent.navigate (WINDOW.LOCATION.HREF);
</script>
That will solve the problem.
PHP is also useful to implement
Copy Code code as follows:
<?php
$url = $_server[' http_host '];
if ($url!= ' www.jb51.net ')
{
Exit ();
}
?>
ASP Implementation Code
Copy Code code as follows:
Yuming=request.servervariables ("SERVER_NAME")
If yuming<> "Www.jb51.net" Then
Response.Redirect "Http://www.jb51.net"
End If
Other languages have similar principles, and you can get the environment variables to get them.
I hope we can help you here.