Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Javascript print with out pop up

Javascript print with out pop up

Scheduled Pinned Locked Moved JavaScript
javascripttutorial
4 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yesu prakash
    wrote on last edited by
    #1

    Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI

    G A A 3 Replies Last reply
    0
    • Y yesu prakash

      Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI

      G Offline
      G Offline
      Gerben Jongerius
      wrote on last edited by
      #2

      How do you mean print, to a physical printer or to be outputted to the page. If it is the latter you could use document.write(), trying to output to a printer is a bit more difficult but not impossible. To do this you could create a new iframe dynamically, point it nowhere and start writing to it with document.write(). All that is left then is calling the .print on that frame.

      1 Reply Last reply
      0
      • Y yesu prakash

        Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI

        A Offline
        A Offline
        Alex Manolescu
        wrote on last edited by
        #3

        Hi, you shoud have a new document with your string and then fire the print event.

        1 Reply Last reply
        0
        • Y yesu prakash

          Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI

          A Offline
          A Offline
          Atulkryadav
          wrote on last edited by
          #4

          Give whatever element u wanna print this id "printMe". Include this script in your head tag:

          var gAutoPrint = true;

          function processPrint(){

          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>\n';

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

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

          else{

          alert("Error, no contents.");

          return;

          }

          html += '\n</BO' + 'DY>\n</HT' + 'ML>';

          var printWin = window.open("","processPrint");

          printWin.document.open();

          printWin.document.write(html);

          printWin.document.close();

          if (gAutoPrint) printWin.print();

          } else alert("Browser not supported.");

          }

          Call the function

          [Print](javascript:void(processPrint());)

          Atul Kumar

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups