javascript - "the remote procedure call failed"- 仅限 IE

标签 javascript .net internet-explorer

我正在尝试使用 javascript 打开一个新窗口,并用当前窗口中的 html 填充它。有点像在新窗口中使用新 css 进行打印预览。

function prnt() {
        var pr = window.open("", "", "width=1020,height=750");
        pr.document.open();
        pr.document.write('<html><head><title>Test</title>');
        pr.document.write('<link href=print.css rel=Stylesheet></head><body>');
        pr.document.write(document.body.innerHTML);
        pr.document.write('</body></html>');
        pr.document.close();
        pr.focus();}  

我从这里调用这个函数:

<a id="print" href="#" runat="server" onclick="javascript:prnt();">PRINT</a>  

IE 给我错误远程过程调用失败,它似乎指向这一行:
pr.document.close();

不过在 FF 中一切正常。有任何想法吗?

编辑
我在 Windows Server 2008 R2 Standard 上运行
SP1

编辑2
如果我删除 pr.document.close(); 页面在 IE 中完美运行,并且 完成 显示在状态栏中。
不过,现在FF不能正常工作了。该页面实际上从未停止加载。我猜它正在等待 pr.document.close(); 命令?

最佳答案

使用 DOM...document.write 是 evil .

如何进行检查 here :

关于javascript - "the remote procedure call failed"- 仅限 IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5580561/

相关文章:

javascript - 为什么单击按钮两次 setInterval 方法比声明的时间短

javascript - 从 jQuery 到普通 JavaScript 的语法。功能不一样

javascript - 循环内的谷歌地图地理编码器

c# - 在 asp.net mvc 的同一 View 中列出和创建

javascript - 下拉菜单在 Internet Explorer 中不起作用

css - 1px 虚线边框在 IE11/Edge 中渲染

javascript - Promise then 不是 Node Promise 的函数错误

c# - Selenium WebDriver 偶尔抛出超时异常

c# - 如何在文本框的 TextChanged 事件中获取文本框的旧文本和更改文本?

javascript - getComputedTextLength 在 IE10 中抛出错误