"the remote procedure call failed" - IE only
I'm trying to open a new window with javascript and fill it with the html from the current window. Sort of like a print preview in a new window and with a new 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();}
I'm calling this function from here:
<a id="print" href="#" runat="server" onclick="javascript:prnt();">PRINT</a>
IE gives me the error the remote procedure call failed and it seems to be pointing to this line:
pr.document.close();Everything works fine in FF though. Any ideas?
EDIT
I'm running on a Windows Server 2008 R2 Standard SP1EDIT2
If I remove pr.document.close(); the page works perfect in IE and done is displayed in the status bar. However, now FF won't work properly. The page never actually stops loading. I guess it's waiting for the pr.document.close(); command?Use the DOM...document.write is evil.
On how to do it check here:
It's not as beautiful as it is an easy solution, but it seem to be working.
I replaced this line of code:
pr.document.close();
with this line:
if (navigator.appName != "Microsoft Internet Explorer") pr.document.close();
精彩评论