Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

include jQuery into javascript and use it in imacros ?

I want to know how can I include jQuery library into javascript and use it in iMacros?

It goes like this. Into .js file I declare iMacros code as a variable

var someMacro;
someMacro ="CODE:";
someMacro +="TAB T=1 
";

The code is actually larger and this is just small example. After I declared the variable I use commands like iimPlay, iimSet etc. to play the macro and set the variables inside the macro.

Now how can I include jQuery library into this so that I can use jQuery inside .js file and enhance my scripts ?

P.S. I found this on their forum but it didn't help me much since I didn't understand how to use it. Here is the link Link to iopus forum about jQuery

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've come with this this solution:

function loadScriptFromURL(url) {
    var request = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Components.interfaces.nsIXMLHttpRequest),
        async = false;
    request.open('GET', url, async);
    request.send();
    if (request.status !== 200) {
        var message = 'an error occurred while loading script at url: ' + url + ', status: ' + request.status;
        iimDisplay(message);
        return false;
    }
    eval(request.response);
    return true;
}

// load JQuery
loadScriptFromURL('http://mysupersecret.blob.core.windows.net/share/jquery-2.0.3.min.js');
$ = window.$,
JQuery = window.JQuery;

Trying to get jQuery from it's official CDN, I faced with the "setTimeout is undefined" error in iMacros. So I downloaded jQuery and modified setTimeout method to be window.setTimeout. This worked for me and so I had to place jQuery in my online shared location to use it from there. Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...