How can get a list of the functions in a javascript file?

后端 未结 4 1202
终归单人心
终归单人心 2021-01-20 14:18

I\'m trying to cobble together a php style include function for javascript. The route I\'m taking is through a XMLHttpRequest. The included file will load, but the functions

4条回答
  •  有刺的猬
    2021-01-20 14:40

    OrbMan pointed me in the right direction on this one, but the solution to this particular method of including Javascript files requires the functions be defined differently; like this

    window.myFunction = function(){ 
    
        alert("Hey There!") 
    
    }
    

    A potential upside to this is that any functions in the included file that are declared the normal way are encapsulated so they are only available to the window.functions from that file... as far as I can tell.

提交回复
热议问题