How can I prevent page opening on an iframe using PHP? Like Gmail inside an iframe?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
For PHP, you can use.
This is only supported in modern browsers, IE8+, Firefox 3.6.9, Safari 4 and Chrome. For older browser, you would also require some JavaScript.
You can do that with JavaScript
This will redirect from page that opens your page in iframe to your page.
You cannot know from PHP code whether the current page is being loaded inside someone's iframe. PHP is run at the server, before anything is sent to the browser.
Only JavaScript, which runs in the browser, can detect if its window is the parent or not and do something about it.