JavaScript print frame button
From D3xt3r01.tk
Info
Let's say you have a page made with frames .. and you want to print one frame easily by pressing a button .. but you don't want that button showing up .. the idea is to put everything inside a div .. and put the print button into another div in the main div .. so when you press that button .. you delete that div leaving the rest of the page without it ready for print out !
Code
Assuming "pagina" is the name of the frame you want to print...
function myprint() {
window.parent.pagina.focus();
var d = document.getElementById('myDiv');
var olddiv = document.getElementById('myprint');
d.removeChild(olddiv);
window.print();
return false;
}
Example
Remember to change the "pagina" word to the name of your frame name... Put the code below in the page of the frame you want to print out...
<html>
<head>
<script type="text/javascript">
function myprint() {
window.parent.pagina.focus();
var d = document.getElementById('myDiv');
var olddiv = document.getElementById('myprint');
d.removeChild(olddiv);
window.print();
return false;
}
</script>
<title>Print test</title>
</head>
<body>
<a href="javascript: myprint();">PRINT</a>
</body>
</html>