我想用javascript登录网站,我不知道是允许的。我在url中使用javascript代码,它在赋值时给了我无效的左侧 at:1:10错误。
javascript:document.getElementById("OtherUsername")="myid";document.getElementById("OtherPassword")="mypassword";$("#btnSend").click();
答案 0 :(得分:1)
正如Vinod所说,你试图将myid
(一个字符串)分配给一个对象document.getElementById("OtherUsername")
。那不行。您需要将其分配给document.getElementById("OtherUsername").value
这应该有效:
javascript:document.getElementById("OtherUsername").value="myid";document.getElementById("OtherPassword").value="mypassword";$("#btnSend").click();
最后一位$("#btnSend").click();
只有在该网站上有jQuery活动,或者你通过某种方式使用插件包含它时才会起作用。
答案 1 :(得分:1)
您无法为dom元素分配值
如果 OtherUsername 元素和 OtherPassword 元素是表单,则可以按照我的代码
document.getElementById("OtherUsername").value="myid";
document.getElementById("OtherPassword").value="mypassword";
$("#btnSend").submit(); //btnSend should be the from id