wagga2650 Posted May 13, 2010 Share Posted May 13, 2010 I have this script that when you place anything in div tags and give the correct ID it will print only that data. I ususlly works fine but since upgrading Firefox to 3.6.3 it only prints a blank page instead of the data on it. Instructions to use: place a div on your page and give it an id="printMe then add some content between the div and then finally add the head and body code and try and print it. Sometimes on Firefox it works for me and others it fails, It works fine in IE. Thanks in advance if anyone can sofrt it out for me. here is the script ------Head code below---- <script language="JavaScript"> var gAutoPrint = true; // Tells whether to automatically call the print function function printMe() { if (document.getElementById != null) { var html = '<HTML>\n<HEAD>\n'; if (document.getElementsByTagName != null) { var headTags = document.getElementsByTagName("head"); if (headTags.length > 0) html += headTags[0].innerHTML; } html += '\n</HE>\n<BODY>\n'; var printareaElem = document.getElementById("printarea"); if (printareaElem != null) { html += printareaElem.innerHTML; } else { alert("OOPS! could not find the printarea function"); return; } html += '\n</BO>\n</HT>'; var printWin = window.open("","printMe"); printWin.document.open(); printWin.document.write(html); printWin.document.close(); if (gAutoPrint) printWin.print(); } else { alert("The print ready feature is only available in modern browsers. Please update your browswer."); } } </script> ---body code for button below <form id="printMe" name="printMe"> <input type="image" name="print" onClick="printMe()" src="images/printme.jpg"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/201592-print-part-of-page-script-help/ Share on other sites More sharing options...
Psycho Posted May 13, 2010 Share Posted May 13, 2010 I'd suggest using CSS to print only selected text on a page instead of making the functionality dependant upon javascript. There have been several posts on these forums on the subject which I have posted solutions for. Quote Link to comment https://forums.phpfreaks.com/topic/201592-print-part-of-page-script-help/#findComment-1057834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.