JavaScript

From Odwiki

Jump to: navigation, search

Introduction

JavaScript (ECMAScript) is a common language used to script various aspects of client-side web pages. Houdini's emebedded browser, hbrowser, has JavaScript capabilities that can be used to interface with Houdini.

RunHCommand

The JavaScript command RunHCommand() is available to JavaScript by including the following line in your page's head section:

<script src="resource:///res/RunHCommand.js"></script>

This command is used to send hscript commands to Houdini and get results back. You don't need to explicitly manage ports since hbrowser manages them for you.

Example

Open hbrowser by clicking on the top right corner "?" icon. Save the following script to file and open it in the browser:


<html>
<head>
    <title>opls</title>
    <script src="resource:///res/RunHCommand.js"></script>
    <script>
        function opls()
        {
            var result;
            var network = document.demo.radius.value;
            result = RunHCommand("opls " + network);
            document.result.text_result.value = result;
        }
    </script>
</head>

<body>
<h1>opls</h1>

<form name="demo">
<b>Network:</b>
  <input type="text" name="radius" value="/obj"></input>
  <input type="button" onClick="opls()" value="opls"></input>
</form>

<form name="result">
  <textarea type="textarea" name="text_result" 
          cols="50", rows="10">
  </textarea>
</form>

</body>
</html>

This script will perform a simple opls on the network you specify.

© 2009 od[force].net | advertise