Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print friendly version

Status
Not open for further replies.

zuza

Programmer
Nov 9, 2003
54
YU
dear all,

I want to add print version of the asp page, for html page I found a javascript file, like this:
<script language="JavaScript">
var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n';

if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}

html += '\n</HE' + 'AD>\n<BODY background="images/background.png">\n';

var printReadyElem = document.getElementById("printReady");

if (printReadyElem != null)
{
html += printReadyElem.innerHTML;

}
else
{
alert("Could not find the printReady section in the HTML");
return;
}
html+='\n\n\n\n\n<img src="file:///Z|/images/hpdlogo.png" width="45" height="45" >\n';
html += '\n</BO' + 'DY>\n</HT' + 'ML>';

var printWin = window.open("","printSpecial");
printWin.document.open();


printWin.document.write(html);

printWin.document.close();



if (gAutoPrint)
printWin.print();
}
else
{
alert("Sorry, the print ready feature is only available in modern browsers.");
}
}

</script>

together with <div id="printReady">

BUT, this works only for HTML pages, for asp pages to take only the content, not the banners and navigation buttons, how can this be possible?

Rgds
ZuZa.
 
u r right,
try an alert()

alert(html)
var printWin = window.open("","printSpecial");
printWin.document.open();


does it have the Gif???

Known is handfull, Unknown is worldfull
 
You can do this purely with CSS style by creating two CSS sheets then assigning one of them media=screen and one of them media=print
Anything you don't ant to have show up in the print media you can simply set their visible:none and you can also change things like the background colors, fonts, etc to make it easier to read.

Here are some links for tutorials/examples:

The w3schools link should cover all the reference type info you need, the others are a simple and more complex tutorial on actually using the media stuff.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top