What should I do if the web page is iframed?
Everyone knows that there is a function called "nesting", but the website you have worked so hard to build is used by someone else to use an iframe to put a vest on you and it becomes the content of his page. Maybe you will be very angry and want to stop it. , so what should you do to avoid preventing web pages from being iframed? Here are several methods to teach you how to prevent your website and web pages from being iframed by others.
(1) The first way to prevent the page from being iframed, add the following JS code to the page:
<script type="text/javascript"> if(top.window.location.href!=window.location.href){ top.window.location.href=window.location.href; } </script>
(2) The second way to prevent the page from being iframed, add the following to the page JS code:
<script type="text/javascript"> if(top.location!=self.location){ top.location=self.location; } </script>
It is said that this solution will keep refreshing the page under Firefox. This is because windows.top is the current window under IE, and if there is no windows.top under Firefox, then it is null. Therefore, this js code will be continuously run, which creates an infinite loop and causes the page to be refreshed all the time.
(3) The third way to prevent the page from being iframed is to add the following JS code to the page:
<script type="text/javascript"> if(window!=parent){ parent.navigate(window.location.href); } </script>
In addition, if you use a web program developed with php, you can also use php directly to implement it. To prevent a page from being iframed, add the following to the program code:
if($_server['http_host']!='www.phpernote.com'){ exit('禁止iframe我的页面!囧'); }
The asp language also has its own unique implementation code for prohibiting a page from being iframed, as follows:
host=Request.ServerVariables("SERVER_NAME") if host<>"www.phpernote.com" then response.redirect "http://www.phpernote.com/" end if
Of course, other programming languages can also be used. The effect of preventing the page from being iframed is achieved by obtaining environment variables. I will not give examples one by one here.
When you want to prevent others from iframe your website or webpage, you might as well try the above method, I hope it can help you.
Related recommendations:
How to use the iframe attribute
A case study on how to asynchronously upload an iframe in a php form file
How to prevent web pages from being nested in iframes?
The above is the detailed content of What should I do if the web page is iframed?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to send web pages to the desktop as a shortcut in Edge browser? Many of our users want to display frequently used web pages on the desktop as shortcuts for the convenience of directly opening access pages, but they don’t know how to do it. In response to this problem, the editor of this issue will share the solution with the majority of users. , let’s take a look at the content shared in today’s software tutorial. The shortcut method of sending web pages to the desktop in Edge browser: 1. Open the software and click the "..." button on the page. 2. Select "Install this site as an application" in "Application" from the drop-down menu option. 3. Finally, click it in the pop-up window

In the Web3 world, although it is free, it is full of dangers. Therefore, the first step in the security of Ouyi wallet is to protect the private key and mnemonic phrase. Everyone knows the importance of private keys, and today the emphasis is on mnemonics. The mnemonic phrase can be understood as another form of presentation of the private key. Having the mnemonic phrase is equivalent to owning the private key and controlling the wallet assets. It is also thought that its presence is lower than that of the private key, and users may forget the mnemonic phrase of Ouyi Wallet. So what should I do if I forget the mnemonic phrase of Ouyi Wallet? Can I still retrieve my Ouyi Wallet mnemonic if I forget it? Issues that users need to pay attention to. Generally speaking, if the mnemonic phrase is forgotten, it cannot be retrieved, but try to contact the relevant customer service personnel for help. The editor below will tell you in detail. What should I do if I forget my Ouyi Wallet mnemonic phrase? If you forget the mnemonic phrase of Ouyi Wallet, please try to recall it or contact us.

The Internet has become an indispensable part of people's lives in today's information age. But we can't get online, and sometimes we encounter some troubles. However, for example, the broadband is already connected. And take corresponding solution measures, we need to troubleshoot the problem step by step to restore the network connection in this case. Confirm the device connection status: Whether the mobile phone and other devices have been correctly connected to the broadband network, check the computer to ensure that the wireless network or wired network connection is normal. 2. Restart the broadband device: Reset the device and re-establish the connection, wait a few minutes and then turn it back on again. Try turning off the broadband router or modem. 3. Check the broadband account number and password: To avoid being unable to access the Internet due to incorrect account or password, make sure the broadband account number and password entered are correct. 4. Check D

In our daily lives, TV, as an important entertainment device, often suffers from snowflakes, which affects our viewing experience. This article will introduce you to practical methods to solve the TV snow problem and help you enjoy TV programs better. 1. Analysis of the causes of snowflake problems Snowflakes appearing on TVs are generally caused by signal interference, antenna problems or TV signal sources. 2. Check whether the antenna connection is loose. First, check whether the connection between the TV and the antenna is firm. If it is loose, plug it in again. 3. Choose a suitable antenna to ensure that the position and direction of the antenna are correct. Choosing an antenna with good performance can improve the signal reception quality. 4. Adjust the direction of the antenna. Find the best signal reception direction by rotating or adjusting the angle of the antenna. 5. Use indoor antenna signals

What should I do if pagefile.sys takes up too much space? In the process of using the computer, we often encounter insufficient memory. In order to solve this problem, the operating system will transfer part of the data in the memory to a special file on the disk. This file is pagefile.sys. But sometimes, we will find that the pagefile.sys file is very large and takes up too much disk space. So, how do we solve this problem? First, we need to clarify the pagefile.sys file

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

The browser cannot open the web page but the network is normal. There are many possible reasons. When this problem occurs, we need to investigate step by step to determine the specific cause and solve the problem. First, determine whether the webpage cannot be opened is limited to a specific browser or whether all browsers cannot open the webpage. If only one browser cannot open the web page, you can try to use other browsers, such as Google Chrome, Firefox, etc., for testing. If other browsers are able to open the page correctly, the problem is most likely with that specific browser, possibly

How to solve the problem of web pages not opening With the rapid development of the Internet, people increasingly rely on the Internet to obtain information, communicate and entertain. However, sometimes we encounter the problem that the web page cannot be opened, which brings us a lot of trouble. This article will introduce you to some common methods to help solve the problem of web pages not opening. First, we need to determine why the web page cannot be opened. Possible reasons include network problems, server problems, browser settings problems, etc. Here are some solutions: Check network connection: First, we need
