8

Is there a way to disable the print preview in Chrome using javascript? I need to open a pop-up in a web application with some text to print; in this pop-up I have the following code when the page is loaded:

$(document).ready(function () {
    window.print();
}); 

a simple JavaScript that opens the print preview page; now, what happens is that the print preview page behaves like a modal dialog: I cannot navigate anymore in the application that has opened the print page (even though the links are clickable). This behavior doesn't show up if the normal system dialog is available (and in fact, I don't have this problem in IE Explorer and in Firefox). So, is there a way to tell Chrome to disable the print preview through a JavaScript?

torox
  • 460
  • 1
  • 3
  • 11
g.cacciapaglia
  • 259
  • 3
  • 9
  • That's so strange that the links are clickable in the print preview--I am certain there is no way to disable it through javascript though. – Dave May 19 '15 at 17:01
  • Hi Dave, what I mean is that the links are clickable not in the print preview but in the original page (the opener). But when I click on those links the application seems freezing (like if a thread is blocked). – g.cacciapaglia May 19 '15 at 17:43

1 Answers1

11

Is there a way to disable the print preview in Chrome using javascript?

No (through javascript). Google like every other company, likes to keep a consistent user experience. If programmers were able to change how chrome worked on different pages beyond html, that would be a poor user experience.

now, what happens is that the print preview page behaves like a modal dialog: I cannot navigate anymore in the application that has opened the print page (even though the links are clickable).

Instead, you could have a new window open with the same data and hava javascript do a print. The previous window would work normally (assuming the new window doesn't open in a new tab because of add-ons/configuration).

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
  • Hi Erik, I already have a new window opened (my fault as I was not clear). I have a page where I show the details of a certain operation (let's say an order); in this page there is a button "Print" which opens another complete separate window which is the popup I was talking about (using a window.open() inside a href tag). So, basically, I'm displaying the data that I want to print in a complete separate window which includes the JavaScript I mentioned in my question. – g.cacciapaglia May 19 '15 at 19:40