1

I want to my webpage to have a print button, Like this.

<button>Print</button>

then when you click the print button. they will pop up a print properties,

Thanks for helping.

2
  • add onclick="print()" Commented Nov 12, 2014 at 0:52
  • alert(window.print===print) proves they are the exact same thing, some people just like using globals... Commented Nov 12, 2014 at 1:02

2 Answers 2

3

This should do the trick. Using JavaScript's print method:

 <button onclick='window.print();'>Print</button>
Sign up to request clarification or add additional context in comments.

8 Comments

There is no document.print(), you should use window.print()
There is no document.print, at least in Firefox. The window.print that is there now is correct.
why does everyone use "window.print()" but just "alert(123)" (no window) ?
@dandavis Were I going to use alert, I would import it into my IFEE via var alert = window.alert; first, or use window.alert.
@janmichaelmallari there is no more code. The print function "comes with the browser".
|
1

This should be as simple as:

<button onclick="window.print()">Print</button>

2 Comments

Alan Can you Do a whole Code for javascript.. for me. Thanks a lot.
Sorry, I'm not sure what you mean by a whole code? window.print() is a JavaScript call, and that's all you need. You could implement a function that called window.print(), but it would be unnecessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.