PHPBuilder - Creating a Printer Version Grab Method Page 10



RSS Twitter
Articles Html

Creating a Printer Version Grab Method - Page 10

by: Jim Fletcher
|
April 1, 2004

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>');
}
Testing it out
In the end you should have the following files:
/print/print.php
/print/print.js
/print/1.html
/print/printmain.gif
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
Good luck!
Jim Fletcher – www.JimFletcher.net

 

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Jim Fletcher

Comment:



Comment:

(Maximum characters: 1200). You have characters left.