Recently, another rogue behavior has become popular in China: using frames (Frames) to embed your web pages into its web pages.
For example, there is a website that claims to be a "reputation aggregation portal" that provides the essence of online forums across the country. However, in fact, it is to use a framework to grab other people's web pages and then add their own advertisements and website logos to it. How is this different from pirated booksellers? !
Prevention method, in
The code copy is as follows:
</body>
Added this code before:
The code copy is as follows:
<script type="text/javascript">
if ( top.location !== self.location )
{
top.location = self.location;
}
</script>
This code is valid. However, there is a problem: after using it, no one can embed your web page into the framework, including yourself.
Is there a way that my web page can only be embedded in my own framework, not someone else's framework?
The code copy is as follows:
<script type="text/javascript">
try{
top.location.hostname;
if (top.location.hostname != window.location.hostname) {
top.location.href =window.location.href;
}
}
catch(e){
top.location.href = window.location.href;
}
</script>
OK, the upgraded version code is completed. Except for local domain names, no other domain names can embed your web page into the framework. My blog uses this code now.