Sign Up! Login: Password: New User? Forgot? Support
Code 
 
 
Forums 
Forums : Forums > Print Forum Post
Mottie (SuperAdmin) 5/17/2009 2:32 PM EST : Printing a Forum Post
ACK!
Mottie
Posts: 3884

0
Like

0
Dislike

Printing a Forum Post

GuildPortal admin site link to original post

This small jQuery script adds a print button under each forum post. After clicking on this button, a popup window opens with a print & close button. You can set the script to auto print the window, but sadly I didn't get the popup window to auto close after printing without messing up in IE so I left it out 

It's best to add the code below into a free form text/HTML box on your forums page. Anyway, I hope someone out there finds it useful.



The Code


This is now a Mod
Control Panel > Site Mods > Get Site Mods >
Look for "Forum Post Print Button"

<script type="text/javascript">
var printButtonURL = "http://i201.photobucket.com/albums/aa236/Mottie1/testsite/icons/forum_print.png";
var autoPrint = true;
var popupWidth = 500;
var popupHeight = 500;

$(document).ready(function(){
 var tmp = '<img class="tooltip" style="cursor:pointer;" src="' + printButtonURL +
  '" alt="Print" title="Print this message" onclick="printWin($(this))">';
 $('.MessageToolsCell1').find('div:first').append(tmp);
})
function printWin(el){
 var msg = el.closest('table');
 var msgContent = msg.find('.MessageBodyCell1').html();
 var pgtitle = msg.parent().find('.MessageSubjectCell1').text();
 pgtitle = pgtitle.replace(/(\s\s)/g,'').replace(/(\t)/g,'');
 var tmp = '<html><head><title>Posted ' + pgtitle + '</title><style media=print>.h,.MessageToonContainer1,.MessageSignature';
 tmp += '{display:none;}</style></head><body><div class=h><input onclick=window.print() type=button value=Print>';
 tmp += '<input onclick=window.close() type=button value=Close><hr></div>' + msgContent + '</body></html>';
 var temp = "menubar=yes,location=no,toolbar=0,status=0,scrollbars=1,width=" + popupWidth + ",height=" + popupHeight;
 var w = window.open ('','Print',temp);
 w.document.write(tmp);
 if (autoPrint) w.print();
}
</script>
Customizing
  • Change the print button image by changing replacing the URL in the "printButtonURL" variable in orange.
  • Stop the message from being automatically printed by setting the "autoPrint" variable to false (in blue).
  • Set the popup window width and height (in pixels) by modifing the numbers in red.
Edit (7/8/2009): Updated & fixed the script to realign the print button
Edit (1/31/2010): Updated the code so the printed page won't show the poster's list of toons and signature.
Edit (10/25/2011): Now a mod
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

Mottie (SuperAdmin) 2/1/2010 1:05 AM EST : RE: Printing a Forum Post
ACK!
Mottie
Posts: 3884

0
Like

0
Dislike

Updated so the printed page won't show the poster's list of character names or signature
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

 
 
Key 
New posts No new posts
New posts ( popular ) No new posts ( popular )
New posts ( sticky ) No new posts ( sticky )
New posts ( locked ) No new posts ( locked )
 
 
Who's Online 
There are   members online.
 
 
So-and-so has logged on!
%title%
%message%