Page 1 of 1

How to execute javascript function directly ?

PostPosted: Wed Nov 20, 2013 9:37 am
by David de Argentina
Hi all,

I has an HTML file with some javascript functions.
In order to put in work, i added into the html, something like this:

Code: Select all
<input type="button" id="Show" value="Show" onclick="FunctionShow()"/>


And, into the NeoBook Program, i has something like this:

Code: Select all
BrowserExecScript "NavegadorWeb1" "document.getElementById('Show').click();" "JScript"


Are there any way to execute the "FunctionShow()" function directly, without calling a button click ?

Thanks in advance,
David de Argentina

Re: How to execute javascript function directly ?

PostPosted: Wed Nov 20, 2013 9:47 am
by dec
Hello,

A possible way can be to use a global variable, something like this:

Code: Select all
<script>
  function Foo()
  {
    alert('Hello from Foo()');
  }
  window.Foo = Foo;
</script>


Then we can use the "BrowserExecScript" action in this way:

Code: Select all
BrowserExecScript "WebBrowser1" "window.Foo();" "JScript"

Re: How to execute javascript function directly ?

PostPosted: Wed Nov 20, 2013 9:59 am
by David de Argentina
Thanks DEC !