PDA

View Full Version : How To Set Auto Print On Print Friendly Version


victoria_1018
11-19-2002, 09:43 AM
My website provide a print friendly version link. However, I shall like to make it auto print when this print version page is loaded.
I had tried different auto print codes on this print friendly version page but it don't work. But all these codes works well on normal web pages.

Does anyone know of any auto print codes that will work on print friendly version page?

Thanks

Victoria

glenngv
11-19-2002, 09:58 AM
try:

function printPage(url,target){
win = window.open(url,target);
win.print();
}

<a href="printpage.htm" target="printPage" onclick="printPage(this.href,this.target);return false;">Printer-friendly version</a>

victoria_1018
11-20-2002, 01:58 AM
Hi glenngv,

The codes you provide on the last mail works, however, another problem occur. No information is display on the print friend version page and a blank page is printed out when the print button is click, I can't figure out why this is happening. However when I remove

onclick="printPage(this.href,this.target);return false;"

the print function is not actived but information can be display.

Thanks

Victoria

glenngv
11-20-2002, 02:15 AM
Can I see the whole <a> tag? Might be the page you are printing is not an HTML page

victoria_1018
11-20-2002, 02:24 AM
Hi glenngv,

My <a></a> code is

<a href="printver.asp?width=500" target="_blank">Printer friendly version</a>

I had also attached my printver.asp together with this reply as I beliveve it is this page that cannot run my code.

Thank You

Regards
Victoria

glenngv
11-20-2002, 02:55 AM
hhmmm you're getting information from another web page and display it as your own. I assume you are aware of its dangers. :D

anyway, try:

function printPage(url,target){
win = window.open(url,target);
win.onload=function(){window.print();}
}

victoria_1018
11-20-2002, 03:18 AM
I actuallu got these code from an asp tutorial website, which is known to be web corner, a link is provided for user to download these codes.

Anyway, the code still don't work and I had deciede to use another method to program this, so thanks for your help.

Regards
Victoria

glenngv
11-20-2002, 03:26 AM
this should work as long as there is no onload event yet in the printver.asp

<html>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<%=title%>
<link rel="stylesheet" href="printver.css">
<%=javascript%>
<script language="javascript">
window.onload=function(){window.print();}
</script>
</head>
<body>

and use the link like this:
<a href="printver.asp?width=500" target="_blank">Printer friendly version</a>

if there is already an onload event handler, just add window.print() there.

victoria_1018
11-20-2002, 03:38 AM
Hi glenngv ,

The code works. Thank You.

Regards
Victoria