Global functions in javascript

后端 未结 6 2146
攒了一身酷
攒了一身酷 2020-12-06 16:43

I\'m new to js and trying to understand global and private functions. I understand global and local variables. But if I have an html named test.html and a 2 js

6条回答
  •  一生所求
    2020-12-06 16:54

    in test2.js you can write this to make the function global

    window.abc = function(){...}
    

    and then in test1.js yo can access it like this

    window.parent.abc();
    

    I hope it will help you

提交回复
热议问题