Previously, this code was used to prevent pages from being used by iframes
< ;script type="text/javascript>
if (top.location !== self.location) {
top.location=self.location;
}
But in Firefox you will find that the page will keep refreshing. The page is not usable at all.
This is because if there is no windows.top in firefox, it will be empty. In IE, windows. Top means that the page in this window is constantly refreshed and this js code is constantly running. This creates an infinite loop, which is why the page keeps refreshing.
So I changed the method and used the following code to be compatible with firefox
This problem is solved.
There is also php to implement
$url = $_server['http_host'];
if( $url != 'www.jb51.net' )
{
exit();
}
? >
asp implementation code
yuming=Request.ServerVariables("SERVER_NAME")
if yuming<>"www.jb51.net" then
response.redirect "http://www. jb51.net"
end if
The principles of other languages are similar, and you can obtain the environment variables.
I hope this can help everyone.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn