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 4 of 4

Thread: Print Button?

  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Print Button?

    Hello,

    I am creating a site that uses frames, and I am going to make some materials that need to be printed, but it sucks when you have the frame printed on the materal as well. Is there a way in javascript to make a button in one of the sites so that people can just click to print out whats on that window of the frame?

    Thanks!

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I guess what you could do is have a button which calls window.open which opens the page that the button is on then call the print function
    Code:
    <input type="button" onclick="newwin=window.open(window.location.href);if(newwin)newwin.print();" value="Print">
    I haven't tested the above. Its just a thought.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Thanks! That works. Do you think there is a way for it to work without popping the new window up? Or does it have to in order to print without the frame?

    Thanks

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You might be able to do something like
    Code:
    <input type="button" onclick="window.frames['framename'].print()" value="Print">
    If the page is on the same domain that should work. If it dosen't then try
    Code:
    <input type="button" onclick="parent.window.frames['framename'].print()" value="Print">
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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