I'm opening an editable form PDF (opened via the acrobat plugin) in an iframe:
<iframe name="iframe_content" id="iframe_content" src="mypdf.pdf"></iframe>
There is a button that calls the following print function:
function printContent(){
window.frames["iframe_content"].focus();
window.frames["iframe_content"].print();
}
It works in Chrome, Safari, IE8, but not in IE9.
In IE9 i receive the following error in reference to the printContent() function:
Invalid calling object
I think this may be the trick to getting it to work, but I'm not sure how to make window.frames fit within this structure: http://msdn.microsoft.com/en-us/library/ie/gg622930%28v=vs.85%29.aspx
UPDATE: Decided that for this single page the simplest solution was forcing the browser into IE8 compatibility mode using the <meta> tag and X-UA-Compatible
You must put your print function inside the Iframe's page and call it from the parent page.
in Iframe:
function printMe() {
window.print()
}
in parent (assuming this is the first iframe on your page):
frames[0].printMe()
Related
Loading a PDF in an <object> tag, I want to show an indicator while the document is being loaded instead of just an empty element, so I positioned a Load Panel over the <object>. I added a function to hide the panel:
function documentLoaded() {
// Code to hide panel here.
}
And set it to fire in the onload event of the <object> tag:
<object type="application/pdf" data="/documents/sample.pdf" onload="documentLoaded();"></object>
This is working exactly how I want it to in Firefox and in Edge, but when I tested it in Chrome the Load Panel never went away. When I debugged it I saw that the documentLoaded() function was never called at any point.
Is there another way to get this to work with Chrome, or another way completely to call a JS function once the PDF is ready?
document.querySelector('#load_panel').onload=documentLoaded()
I have a link:
someText
it works fine everywhere except ie(i try ie11) i have this error
This page can’t be displayed.
Make sure the web address //ieframe.dll/dnserror.htm# is correct.
How can i solve this?
If you use a javascript URI scheme in a HTML href attribute, this is different to using an onclick event handler.
In IE, the result of executing that JavaScript will replace the currently loaded document.
To avoid this (without refactoring your code to not do things this way), you can end your href with the javascript operator void, which tells your javascript to return nothing, at all (well, undefined).
Then IE will stay on the current page.
<a href="javascript:someObject.someFunction(); void 0" ...
...and you probably don't want the target="_blank" since you're telling a new window to run your JavaScript code, and your function is not available in that window.
I would do this instead:
someText
It will open a new tab as you intended, and it works in chrome, firefox and IE.
I'm adding an Iframe to a page by using javascripts document.write. The page (from another domain) that is called inside the Iframe does a bit of setup using
window.addEventListener('load', function() {
//do stuff here
}
It works in Chrome. It works in Firefox. It works in Opera.
It doesn't work in IE9. I get the strangest message, that "the Object does not have the property or method 'addEventListener'". It's apparently the window object IE9 is talking about, because when I
console.log(window)
i get
[object Window]
but when I
console.log(window.addEventListener)
I get
undefined
When I call the page directly the script works fine, but in the Iframe I get this magical castrated window object that does not know addEventListener (and probably other stuff too)?! What the hell is happening here?
After much trial and error I found out that the page that was creating my Iframe had broken HTML (no Doctype, no title tag) and thus forced IE9 into Quirks mode, which apparently means reduced abilities. After cleaning up the loading page it works fine.
Ok, bear with me folks, the setup on this one is long.
I have a simple page. It loads an iframe. Inside that iframe is a form. I want the form inside the iframe to interact with the parent page via jQuery.
This works correctly in Firefox, Chrome, and Safari. See for yourself here:
http://dl.dropbox.com/u/58785/iframe-example/index.htm
However, in Internet Explorer 6/7/8/9, it does not work. The load event fires, but jQuery cannot get a handle on elements inside the iframe.
I'm using the second 'context' argument of the jQuery function to set the context of the selector, like this: var form = $('#myform'), this.contentDocument)
Here's what is batty. Using the F12 Developer Tools in IE9, I can set a breakpoint in my JavaScript and look at how IE is evaluating the JavaScript. If I hover over this, I can see that it does have a contentDocument property. BUT, if I hover over this.contentDocument, it tells me it's undefined.
Because it's undefined, the jQuery selector returns no elements. Again, this is only in IE. And the IFRAME is on the same domain, so it's not a same-origin issue.
Any pointers?
Not to trample on Roatin's answer, but this issue can also be fixed by specifying a DOCTYPE declaraction. Internet Explorer 8 and over require it for contentDocument. Otherwise, as he said, contentWindow can be used (for earlier versions of IE, too). See the information at W3Schools.
I have a link created by the following html/javascript:
Copy Item
myDoc is: top.frames[0].document;
This is supposed to post the form. It works fine in all browsers when run outside an iframe, but, once I get it inside the iframe, it only works in IE and not in Firefox.
What am I doing wrong?
Ok: A follow-up. I got this to work, but now I'm wondering why I was able to. I set myDoc = top.frames[0].document; further up in the form creation and then I try to use it in the link declaration. It works fine in IE. But, when I'm in Firefox, I can't use myDoc. I have to explicitly use top.frames[0].document instead. Why is this?
That's probably because of some security issues. I would suggest putting the form inside the root-document and setting form.target to the name of the iframe.