Load javascript via Firebug console

前端 未结 3 731
星月不相逢
星月不相逢 2020-12-12 17:19

How can I load a javascript file via Firebug console ?

This would be useful in development, so I don\'t have to modify the html code to load the script.

相关标签:
3条回答
  • 2020-12-12 17:28
    var script = document.createElement("script");
    script.src = "http://whatever.com/js/my/script.js";
    document.body.appendChild(script);
    
    0 讨论(0)
  • 2020-12-12 17:34

    Just ran into the same problem, and - as jQuery is used in the project anyway - I decided to do a simple:

    $.getScript('example.js')
    

    Or:

    $.getScript('example.js', function () { doSomethingOnceLoaded(); })
    

    Alternatively, I may code JavaScript directly in Firebug, using the console with the text entry pane on the right side. Activate it with the triangle button in the lower right hand corner.

    0 讨论(0)
  • 2020-12-12 17:44

    A very handy command is include();

    include("http://code.jquery.com/jquery-latest.min.js");
    

    Read more about include() command

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