Home >Web Front-end >JS Tutorial >js method to prevent the page from being called by iframe_javascript skills

js method to prevent the page from being called by iframe_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:32:321387browse

The example in this article describes the js method to prevent the page from being called by iframe. Share it with everyone for your reference. The specific implementation method is as follows:

1. Problem description:

Sometimes we find that our website page is called by others and is exactly the same. This is actually a simple iframe call. Let me introduce to you a summary of js methods to prevent page iframe calls. Friends in need can refer to it.

2. Solution:

Prevent your webpage from being framed:
top.location.href The top address
windows.location.href own address
self refers to the current window object, which belongs to the top-level object of the window;
location.href refers to the URL address of a window object.
self.location.href refers to the URL address of the current window. If self is removed, it defaults to the URL address of the current window

Copy code The code is as follows:

These methods are feasible, but not very reliable.

Copy code The code is as follows:

or
Copy code The code is as follows:

or
Copy code The code is as follows:

or
Copy code The code is as follows:

I hope this article will be helpful to everyone’s JavaScript programming design.

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