javascript frame navigation in ie11 with a pdf

I have a simple web page where 1 frame displays a pdf and another a menu bar.

<iframe src="bar.html" name="menu"  ></iframe>
<iframe src="doc.pdf" name="itempane"   ></iframe>

Using chrome I can navigate from the menu bar to the parent and back down to the frame containing the pdf in order to print it

var pWindow = window.parent;

Attempting to do the same in IE11 gives an Invalid calling object error.

you can see this at

What am I doing wrong / what is IE doing differently?



I think I have proved that this is not a javascript coding issue but related to the pdf handling in IE. With the following page

<a href="javascript:printFromMain('pdfpane');">Print PDF</a><br/>
<a href="javascript:printFromMain('htmlpane');">Print HTML</a>
<iframe src="bar_1.html" name="menu"  ></iframe>
<iframe src="doc.pdf" name="pdfpane"   ></iframe>
<iframe src="doc.html" name="htmlpane"   ></iframe>

and this function

function printFromMain(paneName) {
var pWindow = window[paneName];

the printing of the html page works but not the pdf the pWindow.focus() gives Invalid Calling Object - any insight into why that might be greatfully recieved



After trying several things, I finally go this to work in IE11:

1) use an object tag instead of iframe

2) run focus() / print() directly on the element

3) run after a timeout, to make sure everything in is loaded. There may be a better way (like using some event listener) to do this, as the timeout time needs to be fairly long for it to work properly

setTimeout(function () {
    var contentThingy = document.getElementById('itempane');
}, 4000);

Object (with a specified id) instead of iframe:

<object id="itempane" ... ></object>

Note: doesn't work in chrome. One of the other variations in the other answers (i.e. using ContentWindow) may.


Try actually using the window.frames to get the frameList and reference it by the frame name that way.

var pWindow = window.parent;  //reference the parent from the iframe
var ifr = pWindow.frames.itempane;  //get the pdf frame from the frame list

Try this

<iframe src="bar.html" name="menu"  ></iframe>
<iframe src="doc.pdf" ID="itempane"   ></iframe>

var otherPane = parent.document.getElementById("itempane");
otherPane.focus(); // OR
otherPane.print(); // OR

var doc = otherPane.contentWindow || otherPane.contentDocument;


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.