window.print is not a function()

Hello everyone ,
I have a html (bootsrap ) page .I want to print current page .I created a file css where i defined all css when medai print.
The only problem is that when i tried to window.print() when clicking on a button , it gives me a error  window.print is not a function ?

Can anyone Help me, please?

Paola
PaolaSoftware DeveloperAsked:
Who is Participating?
 
mohan singhConnect With a Mentor Web developerCommented:
Dear Paola

it is simple do like this

<!DOCTYPE html>
<html>
<body>

<p>Click the button to print the current page.</p>

<button onclick="myFunction()">Print this page</button>

<script>
function myFunction() {
    window.print();
}
</script>

</body>
</html>

Open in new window

1
 
PaolaSoftware DeveloperAuthor Commented:
I did it , the problem was that the page was not loaded completely.
Thanks for your attention .
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.