How to implement print effect like this page? [closed]
http://losangeles.kijiji.com/c-PrintAd?AdId=167716102
Viewing the page's source code, I see:
<body onload="OnLoad();window.print();" onunload="OnUnload()">
It's the window.print();
you're interested in.
Although a matter of personal choice, I'm not a fan of web pages invoking system dialogs. It's that whole "don't take control of my computer" thing, like sites that maximize the browser, try to pop-up windows, etc. I'll call a link "Printer Friendly Version" rather than "Print this Page", assuming the user can figure out how to do File -> Print.
Add this to the bottom of a page, and the print dialog will pop up.
<script type="text/javascript">
window.print();
</script>
精彩评论