JavaScript window.print() does nothing

Tags:
JavaScript
I have a web page with JavaScript that: Uses var win = window.open('', '_blank', ''); to create a new window Uses win.document.write(htmlString); to build the new window's HTML. It contains a button with an "onClick" attribute of "window.print();". When the new window's print button is clicked with IE6 (I haven't tested with other browsers), nothing happens - no error, but no Windows print dialog either. I've added alerts to the "onClick" Javascript before and after the window.print statement to make sure that event is being triggered.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I’ve noticed after modifying ESS screens to open a new window or having a print window pop up that it always
failed for certain users. Turned out they had “Pop-up” blockers installed on their browsers which caused it to fail. Just a thought.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Tmjimob
    I saw something about having to call the documents close method newWindow.document.close();
    0 pointsBadges:
    report
  • BrianSchroer
    I added window.document.close(), and it works now. Thanks, tmjimob!
    0 pointsBadges:
    report
  • Tmjimob
    Great! Lucky guess - I didn't really think it would work, but glad it did :)
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following