使用浏览器控制台在Javascript中使用Javascript发送聊天消息 [英] Sending a chat message in Facebook using Javascript using the browser console
问题描述
我正在使用Javascript在Facebook上发送聊天消息,但会收到一条错误消息。它是 TypeError:Object#< NodeList>没有方法'WHATEVERIPUTHERE'
基本上 o
=聊天文本区域。 / p>
o.WHATEVERIPUTHERE(Hello!)
是我正在做的(为文本区域,并发送它)
这是我试过的:
var o = document.getElementsByClassName(uiTextareaAutogrow _552m);
o.WHATEVERIPUTHERE(Hello!);
document.getElementsByClassName
返回一个元素数组。在这种情况下,他们将打开相同的号码。
我用纯粹的Javascript写了:
var o = document.getElementsByClassName(uiTextareaAutogrow _552m);
//设置聊天文本框
var chatTextBox = o [0];
//设置消息值
chatTextBox.value =Hello;
//创建一个keydown事件
var e = new Event(keydown);
//它必须模拟输入按(键代码为13)
e.keyCode = 13;
//触发它
chatTextBox.dispatchEvent(e);
I'm trying to send a chat message in Facebook using Javascript, but keep getting an error message. Either it being TypeError: Object #<NodeList> has no method 'WHATEVERIPUTHERE'
Basically o
= the chat text area.
The o.WHATEVERIPUTHERE("Hello!")
is what I'm trying to do (setting a value for the text area, and sending it)
This is what I have tried:
var o = document.getElementsByClassName("uiTextareaAutogrow _552m");
o.WHATEVERIPUTHERE("Hello!");
document.getElementsByClassName
returns an array of elements. In this case they will have same number with the chat boxes opened.
I wrote it in pure Javascript:
var o = document.getElementsByClassName("uiTextareaAutogrow _552m");
// set the chat textbox
var chatTextBox = o[0];
// set the message value
chatTextBox.value = "Hello";
// create a keydown event
var e = new Event("keydown");
// it has to simulate the Enter press (key code is 13)
e.keyCode = 13;
// trigger it
chatTextBox.dispatchEvent(e);
这篇关于使用浏览器控制台在Javascript中使用Javascript发送聊天消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!