How to execute javascripts on axwebbrowser?

ajaikumarr

Newcomer
Joined
Dec 13, 2003
Messages
9
Hai,

I've a Windows Forms with a Button and AxWebBrowser, and i've loaded AxWebBrowser with a dynamic HTML page (with a javascript function). My problem is, How do i invoke javascript by clicking on the button which is available on Windows forms. (i've tried some thing but no joy...)

Sample HTML Code
---------------------
<html>
<head>
<script language=javascript>
function somefunction() {
alert ("Function sucessfully executed...");
}
</script>
</head>
<body>
bla....bla...
</body>
</html>

in VB.NET
------------
AxWebBrowser.Document.ParentWindow.execScript("somefunction()", "JScript")

Thanks in advance
Ajai Kumar .R
 
do i can set my string value to some javascript code and run it by this command?
like as:
strnig mycode="alert('i am a string')";
brWeb.Navigate("javascript:"+mycode)
 
It should work with any valid java-script code in the string. The easiest way to find out, though, is to try for yourself and see if it works.
 
how to send a javascript objet to a function

Hi,

what if the function to call, has a parameter ((this) like this:

onclick="Myfunction(this);"

how can i call this from vb.net? im using the Navigate method, but cannot send the object since it doesnt have an id or name property...

TKS!
 
Instead of passing "this" you simply reference the object in some way with document.getElementById(...) or something similar like document.window, etc.
 
Gill Bates said:
Instead of passing "this" you simply reference the object in some way with document.getElementById(...) or something similar like document.window, etc.

being tr a table row with a click funtion, that receives an object this, and tr, not having an id or name property, how can i pass the obejct to the js function, using something like the following line of code in vb.net?

WebBrowser.Navigate("javascript:MyFunction(" & tr & '');")

TKS!
 
The problem is that i dont have access to the website ... i have to work with this TR without an id or name and have to do this click function inside it...
 
Back
Top