View Full Version : link element

01-21-2005, 02:25 AM
In the code below, when I click the image to print the alternate page I lose my default style sheet. Why??

<Link rel='alternate' media='print' href=null>
<Script Language=JavaScript>

function setPrintPage(prnThis){

prnDoc = document.getElementsByTagName('link');
prnDoc[0].setAttribute('href', prnThis);

Click to Print Test.html
<img src="print.gif" onclick="setPrintPage('test2.php')">

01-21-2005, 05:32 AM
With what are you loosing the default style sheet? on the printed page or on the current browser window? If it is the printed page then the test2.php would need to have the default style sheet seperatly. But if it is on the current browser window I think it may be because you have a link tag for your style sheet that is before the alternative print page link, changing the number 0 with prnDoc[0].setAttribute('href', prnThis); to correspond to what you actually want to change would work. If the alternative link tag is the 2nd link tag on the page make that 0 to a 1. I was messing around with what you posted and found the same thing happen but relized it was because the 0 was refering to the style sheet link tag.

01-22-2005, 02:49 AM
Thanks for the post it was extremely helpful. I will change the script accordingly and let you know what happens.