首页IT科技iframe vh(iframe内嵌链接常见问题)

iframe vh(iframe内嵌链接常见问题)

时间2025-09-19 08:23:06分类IT科技浏览6436
导读:问题1: Refused to display http://localhost:8080/xxx in a frame because it set X-Frame-Options to sameorigin...

问题1: Refused to display http://localhost:8080/xxx  in a frame because it set X-Frame-Options to sameorigin

出现原因:X-Frame-Options 响应头表示浏览器是否允许一个页面在 <frame>                、<iframe>                       、<embed>         、<object> 标签中显示                。站点维护人员可以通过设置该请求头确保自己的网站没有被嵌入到别人的网站里面                ,从而避免 点击劫持攻击                       。

X-Frame-Options 有三个可能的值:

deny:表示该页面不允许在 frame 中展示                       ,即便是在相同域名的页面中嵌套也不允许        。

sameorigin:表示该页面可以在相同域名页面的 frame 中展示            。

allow-from uri:表示该页面可以在指定来源的 frame 中展示                       。

问题2:This request has been blocked; the content must be served over HTTPS.

出现原因:HTTPS 是 HTTP over Secure Socket Layer        ,以安全为目标的 HTTP 通道            ,所以在 HTTPS 承载的页面上不允许出现 http 请求                       ,因此需要将加载的http请求替换成https请求            ,才能正常显示            。

解决方法:

1.如果iframe加载的内容支持https请求        ,前端可以在页面的<head>中加入以下代码自动将http升级成https                       , 也可以通过后端去配置        。

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

2.如果iframe加载的内容不支持https请求                ,可以让后端通过Nginx拦截转发                       。

        比如: 在https://www.xxx.com下通过iframe内嵌一个http://www.abc.com/aaa    ,前端需要将http://www.abc.com替换成https://www.xxx.com                       ,然后后端要开一个专门的ng服务对该请求进行拦截                   ,再将https://www.xxx.com重新替换成http://www.abc.com                。

问题3:Uncaught DOMException: Blocked a frame with origin "xxx" from accessing a cross-origin frame    。

出现原因:跨域访问                       。

解决方法:百度上很多关于跨域的解决方法                   。

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
phpcms商城模块(phpcms怎么修改模板)