什么会导致页面被取消?我有一个Chrome开发者工具的截图。

这种情况经常发生,但不是每次都发生。似乎一旦缓存了一些其他资源,页面刷新就会加载LeftPane.aspx。真正奇怪的是,这只发生在谷歌Chrome浏览器中,而不是ie8。知道为什么Chrome会取消一个请求吗?


当前回答

你可能想要检查“X-Frame-Options”标题标签。如果它设置为SAMEORIGIN或DENY,那么iFrame插入将被Chrome(和其他浏览器)根据规范取消。

另外,注意一些浏览器支持ALLOW-FROM设置,但Chrome不支持。

为了解决这个问题,你需要删除“X-Frame-Options”标题标签。这可能会让你容易受到点击劫持攻击,所以你需要决定风险是什么以及如何减轻它们。

其他回答

在我的案例中,显示电子邮件客户端窗口的代码导致Chrome停止加载图像:

document.location.href = mailToLink;

移动到$(window)。负载(功能 () {...}) 而不是美元(函数 () {...}) 帮助。

当我用$调用a. js文件时,也发生了同样的情况。ajax,并发出一个ajax请求,我所做的是正常调用。

当我在iframe内的单独域上的安全页面和非安全页面之间重定向时,发生了一个取消的请求。重定向请求在开发工具中显示为“已取消”请求。

我有一个iframe页面,其中包含一个由我的支付网关托管的表单。当iframe中的表单被提交时,支付网关将重定向回我服务器上的URL。重定向最近停止工作,并以“取消”请求结束。

似乎Chrome(我使用的是Windows 7 Chrome 30.0.1599.101)不再允许在iframe内重定向到一个单独域上的非安全页面。为了解决这个问题,我只是确保iframe中的任何重定向请求总是发送到安全url。

当我用一个iframe创建一个更简单的测试页面时,在控制台中有一个警告(我之前错过了或可能没有显示):

[Blocked] The page at https://mydomain.com/Payment/EnterDetails ran insecure content from http://mydomain.com/Payment/Success

在PC、Mac和Android上的Chrome浏览器中,重定向变成了被取消的请求。我不知道这是否是特定于我的网站设置(SagePay Low Profile)或如果Chrome中有什么变化。

我也遇到过同样的问题,在我们的代码深处,我们有这样的伪代码:

创建iframe 加载iframe提交一个表单 2秒后,移除iframe

thus, when the server takes more than 2 seconds to respond the iframe to which the server was writing the response to, was removed, but the response was still to be written , but there was no iframe to write , thus chrome cancelled the request, thus to avoid this I made sure that the iframe is removed only after the response is over, or you can change the target to "_blank". Thus one of the reason is: when the resource(iframe in my case) that you are writing something in, is removed or deleted before you stop writing to it, the request will be cancelled

以我为例,我发现它是jquery的全局超时设置,一个jquery插件设置全局超时为500ms,这样当请求超过500ms时,chrome就会取消请求。