Print IFrame content generated dynamically

43
July 20, 2018, at 10:50 PM

I am trying to print a HTML page in IFrame generated dynamically, with this code bellow:

var jFrame = $("<iframe name='ifm' src='{0}'>".format(url));
jFrame.css("width", "1px")
    .css("height", "1px")
    .css("position", "absolute")
    .css("left", "-9999px")
    .appendTo($("body:first"));
var objFrame = window.frames['ifm'];
$(objFrame).on('load', function () {
    // Only for testing
    console.log(window.frames['ifm'].document.body);
    objFrame.focus();
    objFrame.print();
});
setTimeout(
    function () {
        jFrame.remove();
    },
    (30 * 1000)
);

but when I click to print it, it prints a blank page with only header and footer. The moment that this line is executed: console.log(window.frames['ifm'].document.body);, it prints the iframe body's content correctly, so I assume the iframe's content is loaded, but it is still printing a blank page.

READ ALSO
Jquery Datatable - AJAX- No records handler

Jquery Datatable - AJAX- No records handler

I am loading data into my datatable using ajaxThis is the code:

18
How to make waypoint route from current position to db location

How to make waypoint route from current position to db location

I need to make a way point between the locatonpng to place

33
jQuery plugins not working when using webpack. What is correct way to use it?

jQuery plugins not working when using webpack. What is correct way to use it?

I was try yo use webpack in my developmentI use npm, install jquery and some plugins (YTPlayer, fancybox)

49
Cannot use characters &#39;&lt;&#39; or &#39;&gt;&#39; in jQuery script in WordPress

Cannot use characters '<' or '>' in jQuery script in WordPress

While running my jquery script in wordpress I ran across this weird errorThat does not allow me to use characters '<' or '>' in my script, any surrounding text just disappears during runtime

50