Reputation: 1
I am creating an simple Javascript BOT.Its an simple js bookmarklet when clicked will create blogs in Blogger.com...I used Below code
var script = document.createElement('script');
script.src = 'http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
document.getElementsByClassName('blogg-button GEE3RVNDMU')[0].click()
document.getElementById("newBlog-title").value ="hello blogger";
var node = document.getElementById("newBlog-address");
node.focus();
document.getElementById("newBlog-address").value ="hellosblogger";
setTimeout(function() {game();},1250);
function game()
{
var e = $.Event("keydown", { keyCode: 8});
$("body").trigger(e);
}
Everything works perfect,But atlast I need to simulate Any keypress Event...So i used that in function game , But I get $.Event
is not a function error in Firexfox console . Please some one guide me or please tell any alternative to do an simple keypress event..It can be any key.
Upvotes: 0
Views: 5085
Reputation: 917
There really is no function named Event in the jquery library. To bind a event to jquery object, you can use Jquery.Bind which actually has the same syntax as the one you've used in your code.
So, to summarize:
$.bind("keydown",function(){})
For more info: http://api.jquery.com/bind/
Upvotes: 1
Reputation: 1592
See this link.
All works without errors.
Maybe you should use latest version of jQuery
.
Code:
var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.10.2.min.js';
script.type = 'text/javascript';
script.onload = game;
document.body.appendChild(script);
function game() {
console.log($("body"));
var e = $.Event("keydown", { keyCode: 8});
$("body").trigger(e);
}
Upvotes: 0