I'm trying to click a button on a page and I can get the length of the object no problem but when I try to click the item I get this error:
Error: uncaught exception: [Exception...
"Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"
location: "JS frame :: resource://greasemonkey/runScript.js :: <TOP_LEVEL> :: line 3" data: no]
Here is the code I'm using:
(function(){
$('body').append('<input type="button" id="autobop" value="autobop" />');
$('#autobop').click(function(){
//buJmnfJwRG
alert($('#buJmnfJwRG').length);
$('#buJmnfJwRG').click(); // error occurs here
/*
setInterval(function() {
}, 2000);*/
});
})();
$(document).ready(function(){
$('body').append('<input type="button" id="autobop" value="autobop" />');
$('#autobop').click(function(){
//buJmnfJwRG
alert($('#buJmnfJwRG').length);
$('#buJmnfJwRG').click();
});
});
Link to the target page. Where did #buJmnfJwRG
come from, was it on the target page or added by your script?
Unless #buJmnfJwRG
's click, event handler was created by your script, using jQuery, you cannot activate it using $('#buJmnfJwRG').click();
(usually).
Try:
$('#autobop').click ( function () {
//buJmnfJwRG
alert ( $('#buJmnfJwRG').length );
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
$('#buJmnfJwRG')[0].dispatchEvent (clickEvent);
} );
I had a dev take a look....
$(document).ready(function(){
$('body').append('<input type="button" id="autobop" value="autobop" />');
$('#autobop').click(function(){
//buJmnfJwRG
alert($('#buJmnfJwRG').length);
$('#buJmnfJwRG').click();
});
});
User contributions licensed under CC BY-SA 3.0