raghavendramanandi Posted November 23, 2014 Report Share Posted November 23, 2014 I have a simple HTML code to print the page. Below is the code: <!DOCTYPE html> <html> <head> <script> function printPage() { var w = window.open("http://www.sigmaaldrich.com/catalog/CofADocRequest.do?symbol=209104&LotNo=MKBP0842V&brandTest=SIGMA","_self"); window.focus(); window.print(); } </script> </head> <body > <input type="button" onclick="printPage()" value="print a div!" /> </body> </html> What the code does is, it displays a button, on clicking that button it calls a function. The function uses open() to open a new URL in the same page by using the “_self †parameter. As we can see in the code, the print() is being called after the call to open method. But in my browser IE11, the print pop is being shown befor loading the page. Due to this I am not printing the correct page. Can anybody help me on this. molly1990 1 Quote Link to comment Share on other sites More sharing options...
Jan Posted November 25, 2014 Report Share Posted November 25, 2014 Hi raghavendramanandi, Please try to uncheck "Enable Protected Mode" in internet options. Another advice is "Ensure you are using the default IE security zone settings (Security tab, click "Reset all zones to default"). Placing your window.open statement within a try/catch block will capture failures caused by popup blockers." And this article, it seems, also describes the solution of the problem. I hope, it helps. Quote Link to comment Share on other sites More sharing options...
waleeed12 Posted March 29, 2016 Report Share Posted March 29, 2016 As we can see in the code, the print() is being called after the call to open method. But in my browser IE11, the print pop is being shown befor loading the page. Quote Link to comment Share on other sites More sharing options...
svitlanataran Posted March 29, 2016 Report Share Posted March 29, 2016 Hi waleeed12, I've edited code. Try it. <script> function printPage(){ var w = window.open("enter_URL","_self"); setTimeout(function() { window.focus(); window.print(); }, 1000); } </script> <input onclick="printPage()" type="button" value="print a div!" /> Enter your URL instead of: enter_URL I hope this solution helps. Quote Link to comment Share on other sites More sharing options...
Damen Posted May 29, 2019 Report Share Posted May 29, 2019 On 3/30/2016 at 7:14 AM, svitlanataran said: Hi waleeed12, I've edited code. Try it. <script> function printPage(){ var w = window.open("enter_URL","_self"); setTimeout(function() { window.focus(); window.print(); }, 1000); } </script> <input onclick="printPage()" type="button" value="print a div!" /> Enter your URL instead of: enter_URL I hope this solution helps. I am using the code above and try to print the content of a website. Unluckily, the website is loaded but the print pop up is not shown. Does chrome block this? Any work around? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.