I want to know how can I include jQuery library into javascript and use it in iMacros?
我想知道如何将jQuery库包含到javascript中并在iMacros中使用它?
It goes like this. Into .js file I declare iMacros code as a variable
它是这样的。进入.js文件我将iMacros代码声明为变量
var someMacro;
someMacro ="CODE:";
someMacro +="TAB T=1 \n";
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.
代码实际上更大,这只是一个小例子。在我声明变量后,我使用像iimPlay,iimSet等命令来播放宏并在宏内部设置变量。
Now how can I include jQuery library into this so that I can use jQuery inside .js file and enhance my scripts ?
现在我如何将jQuery库包含在内,以便我可以在.js文件中使用jQuery并增强我的脚本?
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
附:我在他们的论坛上发现了这个,但它对我帮助不大,因为我不明白如何使用它。这是链接到iopus论坛关于jQuery的链接
2 个解决方案
#1
7
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.
试图从它的官方CDN获取jQuery,我遇到了iMacros中的“setTimeout is undefined”错误。所以我下载了jQuery并修改了setTimeout方法为window.setTimeout。这对我有用,所以我不得不将jQuery放在我的在线共享位置以便从那里使用它。希望这可以帮助。
#2
1
Thanks for putting this solution together. I loaded jQuery successfully, then created a bootstrap modal and appended it to the body. Next I attempted to load bootstrap.js and call the modal('show') method on the modal but to no avail. iMacros tells me that the function .modal doesn't exist.
感谢您将此解决方案整合在一起我成功加载了jQuery,然后创建了一个bootstrap模式并将其附加到正文。接下来我尝试加载bootstrap.js并在模态上调用模态('show')方法,但无济于事。 iMacros告诉我函数.modal不存在。
loadScriptFromURL('http://localhost.com:7001/ybswcsstub/resources/plugins/jquery-1.10.2.min.js');
$ = window.$, JQuery = window.JQuery;
$.getScript('http://localhost.com:7001/ybswcsstub/resources/plugins/bootstrap/js/bootstrap.js');
$('body').append('<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
' <div class="modal-dialog">'+
' <div class="modal-content">'+
' <div class="modal-header">'+
' <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>'+
' <h4 class="modal-title" id="myModalLabel">Modal title</h4>'+
' </div>'+
' <div class="modal-body">'+
' Some Modal'+
' </div>'+
' <div class="modal-footer">'+
' <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>'+
' <button type="button" class="btn btn-primary">Save changes</button>'+
' </div>'+
' </div>'+
' </div>'+
'</div>');
$('#myModal').modal('show');
When I run I get the following error in iMacros TypeError: $(...).modal is not a function, line 211 (Error code: -991)
当我运行时,我在iMacros TypeError中遇到以下错误:$(...)。modal不是函数,第211行(错误代码:-991)
Any help would be greatly appreciated as I'm kind of stuck at this point :s
任何帮助将不胜感激,因为我有点卡在这一点:s
Edit:I had to use $.getScript to load the bootstrap.js (the .com in the domain is because of *restriction) as when I tried to use the loadScriptFromURL, I was getting the error
编辑:我不得不使用$ .getScript来加载bootstrap.js(域中的.com是因为*restriction),因为当我尝试使用loadScriptFromURL时,我收到了错误
Error: Bootstrap's JavaScript requires jQuery, line 7 (Error code: -991)
Thanks, Mark.
#1
7
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.
试图从它的官方CDN获取jQuery,我遇到了iMacros中的“setTimeout is undefined”错误。所以我下载了jQuery并修改了setTimeout方法为window.setTimeout。这对我有用,所以我不得不将jQuery放在我的在线共享位置以便从那里使用它。希望这可以帮助。
#2
1
Thanks for putting this solution together. I loaded jQuery successfully, then created a bootstrap modal and appended it to the body. Next I attempted to load bootstrap.js and call the modal('show') method on the modal but to no avail. iMacros tells me that the function .modal doesn't exist.
感谢您将此解决方案整合在一起我成功加载了jQuery,然后创建了一个bootstrap模式并将其附加到正文。接下来我尝试加载bootstrap.js并在模态上调用模态('show')方法,但无济于事。 iMacros告诉我函数.modal不存在。
loadScriptFromURL('http://localhost.com:7001/ybswcsstub/resources/plugins/jquery-1.10.2.min.js');
$ = window.$, JQuery = window.JQuery;
$.getScript('http://localhost.com:7001/ybswcsstub/resources/plugins/bootstrap/js/bootstrap.js');
$('body').append('<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
' <div class="modal-dialog">'+
' <div class="modal-content">'+
' <div class="modal-header">'+
' <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>'+
' <h4 class="modal-title" id="myModalLabel">Modal title</h4>'+
' </div>'+
' <div class="modal-body">'+
' Some Modal'+
' </div>'+
' <div class="modal-footer">'+
' <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>'+
' <button type="button" class="btn btn-primary">Save changes</button>'+
' </div>'+
' </div>'+
' </div>'+
'</div>');
$('#myModal').modal('show');
When I run I get the following error in iMacros TypeError: $(...).modal is not a function, line 211 (Error code: -991)
当我运行时,我在iMacros TypeError中遇到以下错误:$(...)。modal不是函数,第211行(错误代码:-991)
Any help would be greatly appreciated as I'm kind of stuck at this point :s
任何帮助将不胜感激,因为我有点卡在这一点:s
Edit:I had to use $.getScript to load the bootstrap.js (the .com in the domain is because of *restriction) as when I tried to use the loadScriptFromURL, I was getting the error
编辑:我不得不使用$ .getScript来加载bootstrap.js(域中的.com是因为*restriction),因为当我尝试使用loadScriptFromURL时,我收到了错误
Error: Bootstrap's JavaScript requires jQuery, line 7 (Error code: -991)
Thanks, Mark.