中国·深圳
壹品红 - 专注网站托管服务10⁺年
壹品红 - 专注网站托管服务10⁺年

PHP和JS的页面禁止与允许被框架调用

<?php
//示例1html页面禁止被框架调用
header(‘X-Frame-Options: deny’);
//示例2只允许页面被本站调用
header(‘X-Frame-Options: SAMEORIGIN’);
//示例3只允许页面被指定URL嵌套调用
header(‘X-Frame-Options: http://www.feiniaomy.com’);
?>

<script>
if (self == top) { window.open(“index.html”, “_self”); } //如果在框架外部打开则跳转回主页
</script>

<script>
if (self != top) { window.open(“index.html”, “_self”); } //如果在框架内打开的就执行跳转
</script>

<script>
if (self != top) && (location.host.indexOf(“uphong.cn”)>0) { window.open(“index.html”, “_self”); } //只允许页面被指定URL嵌套调用
</script>

需要帮助吗?请加客服微信

推荐阅读:

您使用的浏览器无法保证网站的正常运行,请使用新版浏览器并选择高速模式。

下载Microsoft Edge

Hi,有什么可以帮到您?

工作时间 (GMT+8) 9:00~17:30 周一至周五