JavaScript获取所有加载的脚本 [英] JavaScript Get all Loaded Scripts
问题描述
我正在尝试创建一个Javascript函数,返回所有加载的javascript文件。例如:
我加载jquery.js,jquery.somescript.js和tinymce.js
我想要一个函数以脚本格式返回所有内容(所以如果我要保存并再次运行返回文本),就像我已经调用上述文件一样工作。另外,如果TinyMCE加载了15个JS的fies,它也应该返回。
我希望这不是太混乱了,但任何帮助将不胜感激! p>
感谢提前!
getElementsByTagName 应该让你开始:
var scripts = document.getElementsByTagName('script');
// TODO:循环并阅读src属性
I am trying to create a Javascript function that will return all javascript files loaded. For Example:
I load jquery.js, jquery.somescript.js, and tinymce.js
I want a function to return everything in script format (so if I were to save and run the return text again) it would work just as if I had called the files described above. Also if TinyMCE loads 15 JS fies, it should return as well.
I hope that isn't too confusing to understand, but any help would be greatly appreciated!
Thanks in Advance!
getElementsByTagName should get you started:
var scripts = document.getElementsByTagName('script');
// TODO: loop and read the src attribute
这篇关于JavaScript获取所有加载的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!