问题描述
我创建了一个包含代码的javascript文件,并且在imacros上运行正常。但问题是我需要在另一个javascript文件上执行另一个javascript函数。我尝试了不同的东西,但我不能让它发挥作用。
I created a javascript file with codes in it and is working fine on imacros. but the thing is I need to execute another javascript function on another javascript file. i tried different things but I can't make it work.
我的脚本是这样的
myfunction ();
iimPlay (anotherFIle.js);
所以我的函数会播放一些代码,我做的工作正常。但是当它执行anotherFile.js时,它似乎不起作用。
so my function plays some code that I did which is working fine. But when it's time to execute anotherFile.js it doesn't seems to work.
推荐答案
如果我理解你的问题,那么它是你想要使用函数加载另一个javascript文件,以便能够执行此文件中定义的函数。这可以使用以下函数完成。
If I understand your question right, it is that you want to load another javascript file using a function, to be able to execute functions defined in this file. This can be done using the following function.
function loadJSFile(url){
var script = document.createElement('script');
script.setAttribute('src', url);
script.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(script);
}
并加载(播放)这样的文件:
And load (play) the file like this:
loadJSFile("anotherFile.js");
(不要忘记报价)
这篇关于imacros如何在完成运行javascript函数后播放另一个javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!