Page 1 of 1

NB actions inside webbrowser object

PostPosted: Wed Jan 23, 2013 11:50 am
by dpayer
I hope to launch certain NB actions based on a button click in a webbrowser object.

The following HTML works as expected to display a FileOpen box:

Code: Select all
Click this <a href="neobook:FileOpenBox %22Select File%22 %22Any File *.*%22 %22c:\%22 %22%22 %22%22">link</a>


but this code to create a button to execute the code does not:
Code: Select all
<button onclick="neobook:FileOpenBox %22Select File%22 %22Any File *.*%22 %22c:\%22 %22%22 %22%22">Select</button>


Could anyone explain why the onclick action does not initiate the NB code? Am I making a request to the javascript/jscript engine and not to the IE directly?

The syntax for a button (from W3site) is:
Code: Select all
<button onclick="myFunction()">Click me</button> 

This executes javascript code.

Insight is appreciated.

David P.

Re: NB actions inside webbrowser object

PostPosted: Wed Jan 23, 2013 8:18 pm
by Tony Kroos
onclick is a html event, common syntax for events:
event="language: script", for ex. onclick="javascript:alert('event')"

"Language" parameter defines the language of the script and can take the following values: javascript; jscript; vbscript.
"neobook:..." is not supported

use js function instead:

Code: Select all
<script type="text/javascript">
function Message()
{
window.external.nbExecAction( 'AlertBox "Hello from HTML" "Executing action from HTML source via javascript!"' );
}
</script>

<button onclick="Message()">Click me</button>

Re: NB actions inside webbrowser object

PostPosted: Thu Jan 24, 2013 3:41 am
by dec
Tony Kroos wrote:onclick is a html event, common syntax for events:
event="language: script", for ex. onclick="javascript:alert('event')"

"Language" parameter defines the language of the script and can take the following values: javascript; jscript; vbscript.
"neobook:..." is not supported

use js function instead:

Code: Select all
<script type="text/javascript">
function Message()
{
window.external.nbExecAction( 'AlertBox "Hello from HTML" "Executing action from HTML source via javascript!"' );
}
</script>

<button onclick="Message()">Click me</button>


A good explanation. Thanks Tony! ;)

Re: NB actions inside webbrowser object

PostPosted: Thu Jan 24, 2013 8:29 am
by dpayer
Tony Kroos wrote:onclick is a html event, common syntax for events:
event="language: script", for ex. onclick="javascript:alert('event')"

"Language" parameter defines the language of the script and can take the following values: javascript; jscript; vbscript.
"neobook:..." is not supported

use js function instead:

Code: Select all
<script type="text/javascript">
function Message()
{
window.external.nbExecAction( 'AlertBox "Hello from HTML" "Executing action from HTML source via javascript!"' );
}
</script>

<button onclick="Message()">Click me</button>


Thanks Tony, this is helpful.

When creating functions that are called by an onclick action of a button, would you place this script in the head of the html document or can it be in the midst of the body? Or.... is it your practice to simply execute this script using the BrowserExecScript action?

Also, what characters do you use to enclose the variable name in the jscript when the NB action defines a variable?

David P.