如何阻止来自iframe的请求 [英] How can I block request thats come out from iframe

查看:192
本文介绍了如何阻止来自iframe的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

F.e.我有这样的代码

F.e. I have such code

index.html

index.html

<html>
<head>
    <meta charset="utf-8">
</head>
<body>
    <iframe src="iframe.html"></iframe>
</body>
</html>

iframe.html

iframe.html

<html>
    <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
    </head>
    <body>
        <script>
            $.get("http://badsite.com");
            $.get("http://goodsite.com");
        </script>
    </body>
</html>

如您所见,iframe发出了两个请求,如何阻止对 http://badsite.com 的请求 我需要使用js,php,还是应该配置服务器或更改.htaccess文件?

As you can see iframe make two request and how can I block requests to http://badsite.com What I need to use js, php, or should configure my server or change my .htaccess file?

推荐答案

HTML5引入了 iframe上的沙盒属性,可禁用JavaScript的加载和执行.

HTML5 introduces the sandbox attribute on the iframe that, disables JavaScript loading and execution.

这篇关于如何阻止来自iframe的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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