468

Accessing the browser from JavaScript and Java
Browser content creation functions example code

  • Receive a URL on an input, load it, and output the results
  • Use a Group node to hold the results
  • DEF Loader Script {
        field    SFNode   myself USE Loader
        field    MFString lastUrl ""
        eventIn  MFString loadUrl 
        eventIn  MFNode   vrmlLoaded
        eventOut MFNode   node_changed
        eventOut MFString string_changed
        url "vrmlscript:
            function loadUrl( str, ts ) {
                lastUrl = str;
                Browser.createVrmlFromURL( str, myself, 'vrmlLoaded' );
                string_changed[0] = 'Loading...';
            }
            function vrmlLoaded( nd, ts ) {
                node_changed = nd;
                string_changed[0] = lastUrl[0];
            }"
    }