-2

I have two file:

html2canvas.js

function html2canvas(){

}

myid_print.js

(function ($) {  
    $(document).ready(function() {        
        //I want to call html2canvas function here
        html2canvas();
    });
})(jQuery);

I already included both files in my html but after running the code above, the console shows an error saying:

Uncaught ReferenceError: html2canvas is not defined

How will I call the function from inside my second file?

alyssaeliyah
  • 2,214
  • 6
  • 33
  • 80

2 Answers2

1

Try implementing your Client side code as :

<head>
....
    <script src="html2canvas.js" type="text/javascript"></script> 
    <script src="myid_print.js" type="text/javascript"></script> 
....
<head>
<body>
...
    <script type="text/javascript">
       function_from_myid_print();
    </script>
...
</body>

Inside which you can call html2canvas();

This will surely help you.

For more details refer links:

https://stackoverflow.com/a/3809896/4763053 and https://stackoverflow.com/a/25963012/4763053

Community
  • 1
  • 1
Zealous System
  • 2,080
  • 11
  • 22
0

Try put your JS script at the bottom of your HTML page.

GibboK
  • 71,848
  • 143
  • 435
  • 658
Jack.li
  • 55
  • 2
  • 10