Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: link element

  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    388
    Thanks
    73
    Thanked 0 Times in 0 Posts

    link element

    In the code below, when I click the image to print the alternate page I lose my default style sheet. Why??

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

    function setPrintPage(prnThis){

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

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

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.
    Kris Hubby
    kwhubby site

  • #3
    Regular Coder
    Join Date
    May 2004
    Posts
    388
    Thanks
    73
    Thanked 0 Times in 0 Posts
    Thanks for the post it was extremely helpful. I will change the script accordingly and let you know what happens.
    Tracy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •