I m using the following code to allow me to print multiple coupons on one page. This works great except for when I use IE (any version?) - then I get the error (see attachment):
ie-script-error.jpg
Code:<style type="text/css"> @media print { .noprint { display: none; } .printme { display: block; } } #vehicleOfTheMonth { width: 650px; } .script-errors { width: 650px; font-family: Verdana, Geneva, sans-serif; font-size: 11px; } </style> <script type="text/javascript"> function printDiv( byId ) { // this loop could use getElementByClassName if not using MSIE8 and below var divall = document.getElementsByTagName("div"); for ( var d = 0; d < divall.length; ++d ) { var div = divall[d]; div.className = div.className.replace("printme","noprint"); } // now, turn "on" only one div for printing: var div = document.getElementById( byId ); div.className = div.className.replace("noprint","printme"); window.print( ); } </script> </head> <body> <div class="script-errors"><span style="font-weight:bold">Please note:</span> Some versions of Internet Explorer may give script errors when trying to print. You should still be able to print - just ignore this error please. (Otherwise, please use Firefox, Chrome, Safari or Opera)</div> <!--script errors--> <div id="vehicleOfTheMonth" class="noprint"> <p><img src="parts/vehicle-of-the-month.jpg" width="650" height="700"> <span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#F00; font-weight:bold;">Please print this coupon and present to dealer at time of purchase</span><br /><br /> <input type="button" value="Print Coupon" onClick="printDiv('vehicleOfTheMonth');"/> </p> <p> </p> </div> </body> </html>


Reply With Quote
Bookmarks