Print Selectable Area Of HTML

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Print Selectable Area Of HTML

    This script can be used to print an ary you have selected:

    ADD FOLLOWING SCRIPT TO BODY:
    Code:
    <script type="text/javascript">
    <!--
    function printContent(ID)
    	{
    	str=document.getElementById(ID).innerHTML
    	newwin=window.open('','printwin','left=100,top=100,width=400,height=400')
    	newwin.document.write('<HTML>\n<HEAD>\n')
    	newwin.document.write('<TITLE>ANY TITLE HERE</TITLE>\n')
    	newwin.document.write('<script>\n')
    	newwin.document.write('function chkstate(){\n')
    	newwin.document.write('if(document.readyState=="complete"){\n')
    	newwin.document.write('window.close()\n')
    	newwin.document.write('}\n')
    	newwin.document.write('else{\n')
    	newwin.document.write('setTimeout("chkstate()",2000)\n')
    	newwin.document.write('}\n')
    	newwin.document.write('}\n')
    	newwin.document.write('function print_win(){\n')
    	newwin.document.write('window.print();\n')
    	newwin.document.write('chkstate();\n')
    	newwin.document.write('}\n')
    	newwin.document.write('<\/script>\n')
    	newwin.document.write('</HEAD>\n')
    	newwin.document.write('<BODY onload="print_win()">\n')
    	newwin.document.write(str)
    	newwin.document.write('</BODY>\n')
    	newwin.document.write('</HTML>\n')
    	newwin.document.close()
    	}
    //-->
    </script>
    ADD PRINT BUTTON:
    Code:
    <input type=button value="Print this Page" name="Print" onClick="printContent('print_content');">
    WRAP CONTENT THAT YOU WANT TO PRINT AROUNT THESE DIV TAGS:
    Code:
    <div id="print_content">
    content you want to print
    </div>
    sigpic

    |~~Dont forget to say thanx~~|
Working...
X