I have a page that contains iframes, i want to print them all using window.print() it works in chrome but not working in IE, it just prints the first page not the rest.
it just prints out the first page not other 5 pages.
any help would be much appreciated!
Not clear with your situation but to help, in IE window.print will always try to print the browser window and not the iframe window you are in unlike chrome and firefox.
To print corresponding iframe window in IE, do something like this.
window.top.document.getElementById("iframe-id").contentWindow.focus();
window.top.document.getElementById("iframe-id").contentWindow.print();
Hope this helps.
Related
When printing from windows7 with ie8; only whats visible in viewport is printing.
Printing from windows8 which I believe has ie9 prints the whole webpage with no issue, about 5 pages in total. It will work with compatibly view enabled though.
All is checked from the print prompt so that's not an issue. This was brought to my attention from a user so its not an isolated issue. Any help is appreciated.
I had to set the body to static
body{position: static;}
I am facing a really weird problem. I am calling window.print() from a javascript file. This is working fine in Safari, IE, Firefox... and until two hours ago it worked in Chrome, too. (Version 29.0.1547.57)
I did not change anything essential in my javascript file (really - I just removed some comments...), but what now happens is really weird: In Chrome, the print dialogue does not open when window.print() is called. Nothing happens. But then, when I press reload, the print dialogue opens immediately.
The behaviour in the other browser did not change. And while debugging in Chrome I can see that window.print() is called as expected and the script goes on after that. Only the print dialogue is not shown until pressing reload.
Has anybody ever experienced something like that? I also tried to call window.print() in setTimeout(), but this did not change anything. When I debug the content of the page which shall be printed appears to be perfectly loaded.
I am sorry to ask, but I did not find anything while researching. Any help would be appreciated!
Thank you!
Wasiim is right, there is a Chrome bug where window.print() does not work when there is a <video> tag in the DOM. I solved it by calling this function:
function printPage() {
window.print();
//workaround for Chrome bug - https://code.google.com/p/chromium/issues/detail?id=141633
if (window.stop) {
location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear
window.stop(); //immediately stop reloading
}
return false;
}
From my experience this is due to continued background traffic, e.g. ajax calls and the like that prevent Chrome from feeling the that page is loaded completely. The reload breaks all traffic and thus the print dialog pops up.
This is a particular gotcha in Visual Studio 2013 where BrowserLink continually ticks away in the background.
This can be tested by disabling BrowserLink via the setting below:
<configuration>
<appSettings>
<add key="vs:EnableBrowserLink" value="false"/>
</appSettings>
</configuration>
I have exactly same problem with Chrome. You need to manually reload page:
Print
If by any chance someone is using VS2013 with chrome, this problem is caused by the BrowserLink funcionality.
see SO answer here
Similar behavior in Safari. It is caused by opened HTTP request(s) on background.
When any HTTP request is in progress, window.print() is executed successfully, but no dialog is opened!
You will have this issue, when you use a long polling (for server push). Because client will have already opened HTTP connection for a long time, window.print() will never work.
I am most certain you are experiencing this issue because you have a video element on your page - most probably an MP4.
If you disable this video / or have an OGV video instead, the printing should work fine.
It is a bug in chrome itself due to limitations of Chrome's video implementation. It is also important to note that if the user prints manually with ctrl-p / cmd-p, print functions correctly
http://code.google.com/p/chromium/issues/detail?id=141633
Hope this helps :)
I have an alert box, and when I run that code in Firefox, no matter what program I have over firefox, firefox appears with the pop-up automatically over other programs open.
This however, does not work in Chrome.
What gives? Would this be a perference change or this there a line of code that says focus on this window.
I used
window.blur();
window.focus();
and that fixed my problem :)
The implementation of alert is browser specific. Unfortunately there is not line of javascript code to change this.
If you want to have customizable (and working the same in every browser) alert window, use jquery UI.
Note: It will be over the actual page, not over the (other) window.
Can any one tell me the complete cross browser solution to print the contents of iframe.I followed the following links.But it is not working in chrome 3.0 browser & IE8.It is printing the entire page.
How do I print an IFrame from javascript in Safari/Chrome
Print iframe content in Opera and Chrome
Thanks for your valuable help...
As to Chrome, version 3 is way ancient. Please give a try to some newer version (like Chrome 16) and see if it works there.
I'm using window.print() from inside an iFrame. This works flawlessly in FF, but not so great in IE7. In IE7, it brings up the Print Dialog, however, the dialog itself is slow, choppy and unstable.
I'm having troubles understanding this problem, and any help would be greatly appreciated.
If I may add, the same thing happens when printing content of the same iFrame from outside of the iFrame in question. Further more, when clicking File->Print the Print Dialog appears to function normally.
Try using:
document.execCommand('print', false, null);
This appears to work in IE7, but you'll probably want to use a conditional and use window.print() for other browsers.