问题
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.
my script is something like this
myfunction ();
iimPlay (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.
回答1:
You can add anotherFIle.js to bookmarks and then call it by iimPlay("CODE:URL GOTO=[bookmark_link]"). If anotherFIle.js in root folder of iMacros, try this:
myfunction ();
iimPlay("CODE:URL GOTO=imacros://run/?m=anotherFIle.js",60);
回答2:
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");
(don't forget the quotes)
来源:https://stackoverflow.com/questions/17511047/imacros-how-do-i-play-another-javascript-file-after-finish-running-a-javascript