imacros how do I play another javascript file after finish running a javascript function

怎甘沉沦 提交于 2019-12-08 11:42:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!