如何在Chrome控制台中包含JavaScript文件或库? [英] How to include JavaScript file or library in Chrome console?
本文介绍了如何在Chrome控制台中包含JavaScript文件或库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Google Chrome浏览器中是否有一种更简单的方法(可能是本机?)包括外部脚本文件?
Is there a simpler (native perhaps?) way to include an external script file in the Google Chrome browser?
当前我正在这样做: / p>
Currently I’m doing it like this:
document.head.innerHTML += '<script src="http://example.com/file.js"></script>';
推荐答案
appendChild()
是一种更本地的方式:
appendChild()
is a more native way:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'script.js';
document.head.appendChild(script);
这篇关于如何在Chrome控制台中包含JavaScript文件或库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文