-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
  • 1,882
  • 3
  • 27
  • 68

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,059
  • 9
  • 22
0

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

GibboK
  • 68,054
  • 134
  • 405
  • 638
Jack.li
  • 55
  • 2
  • 10