允许页面仅加载到iframe中并阻止直接访问 [英] Allow a page to only load in an iframe and prevent direct access

查看:98
本文介绍了允许页面仅加载到iframe中并阻止直接访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何才允许我的PHP文件仅加载到iframe中?

How can I allow my PHP file to only load in an iframe?

例如:

阻止直接访问:

example.com/Loader.php

允许iframe访问:

<iframe name="TEST" src="Example.com/Loader.php"></iframe>


推荐答案

您可以使用JavaScript

You can use JavaScript for that

if(window==window.top) {
    // not in an iframe
}

这篇关于允许页面仅加载到iframe中并阻止直接访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆