Dynamically load JavaScript with JavaScript

后端 未结 1 1186
终归单人心
终归单人心 2021-01-19 04:26

After over an hour of trying to get it to work I\'m thinking it\'s because of cross domain policies, but I really thought this would work. I can\'t find a lot of info on it

相关标签:
1条回答
  • 2021-01-19 05:11

    You just have a minor error:

    fileref.onload = callback();
    

    This will call callback immediately and assign its return value to fileref.onload.

    It should be

    fileref.onload = callback;
    

    You also should add the handler before you set the source (just in case).

    DEMO

    0 讨论(0)
提交回复
热议问题