The randomname() function creates a random name for the opened window.
This helps prevent some cache issues.
function randomname(str)
{
var ret = new String("");
var ch;
for (var i = 0; i < str.length; i++)
{
ch = str.charAt(i);
if (ch == ".")
ret += "X";
else
ret += ch;
}
return ret;
}
function showprinterversion(company, button)
{
var name = randomname(Math.random().toString());
var url = "http://www.yourdomain.com/print/print.php?company="
+ company + "&url=" +escape(location.href) + "&title="
+ escape(document.title);
window.open(url, name,
'height=580,width=530,toolbar=0,menubar=no,directories=no,resizable=1,
scrollbars=1,status=0');
return;
}
function showbutton(company, button)
{
document.write('<br>');
document.write('<table border="0" cellspacing="0"
cellpadding="0"');
document.write('<tr><td align="middle" valign="top">');
var link = "<a name='printerversionlink' href='#'
onClick='javascript:showprinterversion(\"" + company
+ "\", \"" + button + "\");
' target='_self'>";
document.write (link);
var btn = "<img name='printerversionbutton'
src='http://www.yourdomain.com/print/print" + button
+ ".gif' border=0>";
document.write (btn);
document.write('</table>');
}
I also include some images to use in the template:
/print/clickheretoprint.gif
/print/closewindow.gif
the sample SQL needed to set up your database:
SQLsetup.txt
and an example page that shows how to use the include and exclude tags:
example.html