I am trying to implement the print preview on a page that opens as pdf format.However, when the page opens , the print function is not executed and nothing happens. What could I be doing wrong? I am using Python with Django and I want to implement the print function using javascript.
Asked
Active
Viewed 53 times
0
-
Did you ever get to solve you issue? – Ralf Apr 24 '18 at 14:27
1 Answers
1
Try function assignment without executing the function (without parathesis).
window.onload = funcloadprint;
And maybe put the assigment after the declaration, not before.
A little suggestion
It is good practice to wrap your javascript code in a closure to avoid global namespace polution. Its not necessary for this small case, but it would be good for your future projects to read up about it.
(function() {
function funcloadprint() {
...
};
window.onload = funcloadprint;
})();

Ralf
- 16,086
- 4
- 44
- 68
-
Did this help you? Could you get it working? If so, I would appreciate if you marked the answer as accepted. – Ralf Apr 20 '18 at 19:09