Writing to a new window with javascript... get access denied
Posted
by Søren
on Stack Overflow
See other posts from Stack Overflow
or by Søren
Published on 2010-04-09T10:37:07Z
Indexed on
2010/04/09
10:53 UTC
Read the original article
Hit count: 428
JavaScript
Hello gurus :)
I have been struggling with this for a while now, and decided it was time to ask for help.
I am trying to create a print function on an aspx page, and I am using javascript to do this:
function PrintContentCell() {
var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
var content_innerhtml = document.getElementById("testTable").innerHTML;
var document_print = window.open("Loading.htm", "", display_setting);
document_print.document.open();
document_print.document.write('<html><head><title>Print</title></head>');
document_print.document.write('<body style="font-family:verdana; font-size:12px;" onLoad="self.print();self.close();" >');
document_print.document.write(content_innerhtml);
document_print.document.write('</body></html>');
document_print.print();
document_print.document.close();
return false;
}
I get "Access Denied" when the script tries to write to the new window. The Loading.htm file is just a very slim html document writing out the text "Loading...". I had hoped this would work after reading this thread: http://stackoverflow.com/questions/735136/ie-6-7-access-denied-trying-to-access-a-popup-window-document
Anybody can help?
© Stack Overflow or respective owner