var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
var printwin = window.open('', 'printwin', display_setting )
printwin.document.open()
printwin.document.write("Testing")
printwin.document.close()
Why does the above code generate a "Permission Denied" error in IE9, but works perfectly fine on Firefox or Chrome? Is there a work around? It is an ExtJS 4.1 application is running on an intranet from a single domain. It uses the ExtJS history feature which may be a factor.
Thanks
var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
var printwin = window.open('', 'printwin', display_setting )
printwin.document.open()
printwin.document.write("Testing")
printwin.document.close()
Why does the above code generate a "Permission Denied" error in IE9, but works perfectly fine on Firefox or Chrome? Is there a work around? It is an ExtJS 4.1 application is running on an intranet from a single domain. It uses the ExtJS history feature which may be a factor.
Thanks
Share Improve this question edited Jan 9, 2013 at 12:03 BigBadOwl asked Nov 26, 2012 at 11:47 BigBadOwlBigBadOwl 6782 gold badges9 silver badges23 bronze badges 1- Working in mine. But can't close – Akhil Sekharan Commented Nov 26, 2012 at 11:52
5 Answers
Reset to default 4I have tested with the above code, in IE I have found only one issue, that is in the last line you haven't declared the object win... if you give the details of your requirement then I will help. I have modified your code and tried its works fine for me in IE.
Here is the test code. If you want to close the window use printwin.close()
instead of printwin.document.close()
.
<script type="text/javascript">
function openwindowIE(){
var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
var printwin = window.open('', 'printwin', display_setting )
printwin.document.open()
printwin.document.write("Testing")
printwin.document.close()
}
</script>
<input type="button" onclick="openwindowIE()" value="go" />
If I'm not mistaken, IE thinks, that about:blank (which you are trying to open, I guess) is an insecure website and thus you aren't allowed to municate with it.
If I'm not mistaken, you could open any other (empty) html document and write in it, instead.
This is a bit of a long shot but have you closed all IE windows and tested this? The possibility I am thinking about is that while testing you may have opened a window named printwin
and then you navigated away from the base page (or opened it in a new tab or trying to open more than one window named printwin
) and are again trying to open the window with name printwin
. The printwin
window was already open but the base page does not have permission to access it since it is not the original opener of the page.
The key point here is that the window name should always be unique.
try this:
var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
var printwin = window.open('about:blank', 'printwin', display_setting);
printwin.document.open();
printwin.document.write("Testing");
printwin.close();
test
After all this, it turns out that one of the included scripts contained the line
document.domain = document.domain;
Everything works after it is removed.