How does the Javascript print function work? Can I create a document using javascript and print it off?

后端 未结 8 1686
梦毁少年i
梦毁少年i 2021-02-09 07:17

I know you can use window.print() to print the current page... but what I want to know is can I build a document using javascript in order to populate it with data and print it

8条回答
  •  春和景丽
    2021-02-09 07:43

    If you are doing this while the document is being loaded, you can use document.write to write the current document, then print it.

    If the page has finished loading, you can use functions to manipulate the DOM, or preferably use a library such as jQuery or Prototype, then print the current document.

提交回复
热议问题