SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help converting button to html link

    I'm using the following code to bring up a print dialog. I was wondering how I could convert this to a text link or image link instead of the button. I'm a real noob at javascript, I'm thinking it's probably quite easy.

    <script type="text/javascript"><!--
    if (window.print) {
    document.write('<input type="button" onclick="window.print()"'+
    ' value="Print">'); }
    //--></script>

  2. #2
    SitePoint Enthusiast BarbaraStreisand's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simply make a function out of it, then call the function in the "onclick" method of a link.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Text:

    <script type="text/javascript">
    if (window.print) document.write('<a href="#null" onclick="window.print();return false">Print</a>');
    </script>

    Image:

    <script type="text/javascript">
    if (window.print) document.write('<a href="#null" onclick="window.print();return false"><img.... /></a>');
    </script>
    ::: certified wild guess :::

  4. #4
    SitePoint Evangelist vikrantkorde's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai, India
    Posts
    541
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you don't want that link to be printed then u can set the visibility property to false just before it prints. and then again make it true again.

    onClick = "this.visibility=false; window.print(); this.visibility=true;"
    Vikrant Korde
    S Y S T I M E, Mhape,
    Mumbai, Maharashtra, India.

  5. #5
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'll try out your suggestions.

  6. #6
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a way to have it print automatically to the default printer without having the windows print dialog box come up?

    Quote Originally Posted by vikrantkorde
    if you don't want that link to be printed then u can set the visibility property to false just before it prints. and then again make it true again.

    onClick = "this.visibility=false; window.print(); this.visibility=true;"


Bookmarks

Posting Permissions

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