minoset
minoset

Reputation: 78

Javascript function call in url

I want to login a website with javascript and i dont know it is allowed. I use javascript code in url and it gives me Invalid left-hand side in assignment at :1:10 error.

javascript:document.getElementById("OtherUsername")="myid";document.getElementById("OtherPassword")="mypassword";$("#btnSend").click();

Upvotes: 0

Views: 53

Answers (2)

Carson
Carson

Reputation: 152

you can not Assign a value to a dom element

if OtherUsername element and OtherPassword element is a form you can follow my code

document.getElementById("OtherUsername").value="myid";
document.getElementById("OtherPassword").value="mypassword";
$("#btnSend").submit(); //btnSend should be the from id

Upvotes: 1

Joe Davy
Joe Davy

Reputation: 783

As Vinod stated, you are trying to assign myid (a string) to document.getElementById("OtherUsername"), an object. That won't work. You need to assign it to document.getElementById("OtherUsername").value

This should work:

javascript:document.getElementById("OtherUsername").value="myid";document.getElementById("OtherPassword").value="mypassword";$("#btnSend").click();

The last bit $("#btnSend").click(); will only work if they have jQuery active on that site, or if you include it through use of a plugin somehow.

Upvotes: 1

Related Questions