Tuesday, August 04, 2009

Javascript printing in Safari

Because safari seems to cheat with browser speed tests and calls javascript before the page has finished rendering, I ran into a problem with having a javascript windows.print(); function on the page, the print box would come up before the page had finished loading.

Took me a while to figure out a solution, but by making the body tag a server control, I could call:
body.Attributes.Add("onload", "javascript: window.print();");

To programmatically add the javascript, which would only load _after_ the page had rendered.

Labels: , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home