Jump to content

[Help] executeBrowserJavascript


Shuubaru

Recommended Posts

Hello, I'm having some problems with this functions as I'm not familiar with javascript, I'm working with a HTML login which is almost done except for one thing, the user data saving. I've seen some "examples" about the use of javascript in login panels and follow the examples didn't work in any way.

I just want to load the username and password from some xml and then autofilling them on the login panel, like this:

AnVobDe.png

This is what I tried:

HTML

			<form action="javascript:loginTrigger()" method="post">
				<input id="UsernameInput" type="text" class="username" placeholder="Username">
				<input id="PasswordInput" type="password" class="password" placeholder="Password">
				<button type="submit" class="log_button">Login</button>
				<div class="error"><span style="color:#999">+</span></div>
			</form>

LUA

username = magicalFunctionThatLoadTheUsername()
password = magicalFunctionThatLoadThePassword()

executeBrowserJavascript(theBrowser, 'document.getElementById("UsernameInput").val = "'..username..'";')
executeBrowserJavascript(theBrowser, 'document.getElementById("PasswordInput").val = "'..password..'";')

 I'm not experienced with javascript (as you can obviously see) but I don't really get why it does not work as I'm follow the same steps as other examples I've seen around the web.

Link to comment
3 hours ago, anchor said:

 


object.value = "text"; //setter

object.value; //getter

learn more about html dom and js > https://www.w3schools.com/jsref/prop_text_value.asp

Well, it's seems the problem was that executeBrowserJavascript function was called first, before that the page itself were loaded... I've used a timer to call that function in 2 seconds and now it does work in the way I want:
 

setTimer(executeBrowserJavascript,2000,1,theBrowser, "document.getElementById('UsernameInput').value = '"..username.."';")
setTimer(executeBrowserJavascript,2000,1,theBrowser, "document.getElementById('PasswordInput').value = '"..password.."';")

 

Edited by Shuuichi
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...