通过JavaScript发送的Facebook聊天消息 [英] Send Facebook chat messages via JavaScript
问题描述
我写一个Firefox插件,它应该能够发送/截取的Facebook聊天消息,而在浏览器中聊天。
I am writing a Firefox addon, which should be able to send/intercept Facebook chat messages, while chatting in the browser.
我能够拦截的消息,但我不知道,如何触发邮件发送自主事件。
I am able to intercept messages, but I don't know, how to trigger the message sending event autonomously.
因为我无法找出如何使用于发送消息我Ajax请求,我的做法是,以填补聊天框文本区域
,然后触发<$ C C>的keydown - 活动为$ ENTER
来创建和提交信息。
As I could not find out how to make the ajax request for sending a message myself, my approach was to fill the chat box textarea
and then trigger the keydown
-Event for ENTER
to create and submit a message.
我想有一个更合适,更清洁的方式做到这一点? 我怎样才能触发AJAX事件通过JavaScript发送消息在一个开放的客舱?
I guess there is a more appropriate and clean way to accomplish this? How can I trigger the AJAX event for sending a message in an open chatbox via JavaScript?
推荐答案
要火从一个文本框中输入一个AJAX请求是检查字符code,你输入,这对于进入将是
To fire an AJAX request from a text box input would be to check the character code that you input, which for enter would be
if(characterCode == 13)
然后哪个可以用于触发请求;一个完整的例子是
Which could then be used to fire the request; a full example would be
$("textarea").live("keydown",function(e){
if (e.which == 13){
$.ajax({
//you know the rest
});
}
});
这篇关于通过JavaScript发送的Facebook聊天消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!