在子窗口上打开打印预览时,Google Chrome会阻止ajax请求

Joh*_*ith 19 javascript ajax google-chrome

有2个文件:index.htmlprint.html

第一个包含一个print.html使用简单命令打开的按钮:

window.open("print.html", "_blank", "menubar=yes,toolbar=yes,status,scrollbars,resizable");
Run Code Online (Sandbox Code Playgroud)

print.html 仅包含一个用于打开打印预览对话框的按钮:

<button onclick="window.print();">
Run Code Online (Sandbox Code Playgroud)

打开打印预览对话框时出现问题.在这种情况下,任何操作index.html- 即启动ajax请求的其他文件 - 都会被临时阻止并放入队列.只有在预览关闭时,浏览器才会触发所有请求.

我只能在谷歌浏览器(24.0.1312.52米)中看到它.

任何人都可以确认这是Chrome的错误吗?

dim*_*gfx 0

我在 Chrome 上遇到了类似的问题 - 由于安全策略,它无法访问本地文件。当我进行 AJAX 调用时,出现此错误

XMLHttpRequest cannot load file:///*. Origin null is not allowed by Access-Control-Allow-Origin.
Run Code Online (Sandbox Code Playgroud)

据我所知 - 你应该使用参数启动 Chrome:

--allow-file-access-from-files
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你。