Source language: Translate to:

NB actions inside webbrowser object

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

NB actions inside webbrowser object

Postby dpayer » Wed Jan 23, 2013 11:50 am

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: NB actions inside webbrowser object

Postby Tony Kroos » Wed Jan 23, 2013 8:18 pm

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>
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: NB actions inside webbrowser object

Postby dec » Thu Jan 24, 2013 3:41 am

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! ;)
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: NB actions inside webbrowser object

Postby dpayer » Thu Jan 24, 2013 8:29 am

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest