Home  >  Article  >  Web Front-end  >  JavaScript implements code sharing to prevent web pages from being embedded in Frame_javascript skills

JavaScript implements code sharing to prevent web pages from being embedded in Frame_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:23:191147browse

Recently, another rogue behavior has become popular in China: using frames to embed your web pages into other web pages.
For example, there is a website that claims to be a "word-of-mouth aggregation portal" that provides the best content from various online forums across the country. However, in fact, it uses a frame to crawl other people's web pages, and then adds its own advertisements and website logos on it. How is this different from a pirated bookseller? !

Prevention method, in

Copy code The code is as follows:


Add this code before

:


Copy code The code is as follows:



This code is valid. However, there is a problem: after using it, no one can embed your web page into the frame, including yourself.

Is there a way so that my webpage can only be embedded in my own frame, not someone else's frame?

Copy code The code is as follows:


Okay, the upgraded version of the code is completed. Except for local domain names, other domain names cannot embed your web page in the frame. My blog now uses this code.

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