Welcome Guest Search | Active Topics | Sign In | Register

Found webview1.evalscript execution part JS invalid Options
kevin_ll
Posted: Tuesday, August 30, 2016 1:13:48 PM
Rank: Member
Groups: Member

Joined: 12/10/2015
Posts: 17
For example: Web page code
Code: HTML/ASPX
<body>
<input type=file id="file">
<body>


VB code:This click event does not work
Code: Visual Basic.NET
Dim JsCode As String="document.getElementById('file').click();"
WebView1.EvalScript(JsCode)





kevin_ll
Posted: Tuesday, August 30, 2016 1:22:27 PM
Rank: Member
Groups: Member

Joined: 12/10/2015
Posts: 17
This example is also invalid
Code: Visual Basic.NET
Dim JsCode As String="document.getElementById('file').click();"
WebView1.GetDOMWindow.InvokeFunction("eval",JsCode)


This example can be
Code: Visual Basic.NET
WebView1.LoadUrl("JavaScript:document.getElementById('file').click();")


This is not Bug's EO.Webbrowser?
kevin_ll
Posted: Tuesday, August 30, 2016 3:32:34 PM
Rank: Member
Groups: Member

Joined: 12/10/2015
Posts: 17
This method is not.
Code: Visual Basic.NET
WebView1.QueueScriptCall


Excuse me, what is the difference between WebView1.QueueScriptCall and WebView1.EvalScript?
eo_support
Posted: Tuesday, August 30, 2016 7:31:18 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

The above script doesn't do anything in Chromium V49, which is the version the current EO.WebBrowser is based on. It appears that this behavior was changed in newer versions. So we should have the same result the next time we sync to Chromium's codebase.

The primary difference between EvalScript and QueueScriptCall is EvalScript is synchronous, while QueueScriptCall is asynchronous.

Thanks!
kevin_ll
Posted: Tuesday, August 30, 2016 9:31:13 PM
Rank: Member
Groups: Member

Joined: 12/10/2015
Posts: 17
But it is possible to be directly on the web page.
for example
Code: HTML/ASPX
<head>
<script type="text/javascript">

function abc(){
	window.eval("document.getElementById(\"file\").click();");
}

</script>
</head>


<body>

<input type=file id="file" name=file>

<input type="button" value=openfile onclick="abc();" id="but1">

</body>



kevin_ll
Posted: Tuesday, August 30, 2016 9:43:19 PM
Rank: Member
Groups: Member

Joined: 12/10/2015
Posts: 17
I used to do the simulation page click on the software, if this step can not be the correct implementation of the trouble.
eo_support
Posted: Wednesday, August 31, 2016 1:18:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

This has to do with how Chrome verifies click event. Specifically for file input control, chrome check whether it is associated to a real mouse click or not (probably for security reasons). For example, while the following code works:

Code: HTML/ASPX
onclick="abc()"


If you change it to:

Code: HTML/ASPX
onclick="setTimeout('abc()', 3000);"


Then it will not work. The later does not work because by the time "abc()" is called, there is no associated mouse click event since the original click event is long gone and this particular call is triggered by a timer.

Chrome might have changed this in newer builds. In that case you will get the update when we update to the new engine. However we are not in a position make these kind of changes on our side since it can get out of control very quickly as Chrome is an extremely large project.

Thanks!
kevin_ll
Posted: Monday, September 5, 2016 12:39:33 PM
Rank: Member
Groups: Member

Joined: 12/10/2015
Posts: 17
thanks eo_support

Now this is the only way to achieve this function.
Code: Visual Basic.NET
WebView1.LoadUrl("JavaScript:document.getElementById('file').click();")


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.