From: Bob Crispen <crispen@hiwaay.net>
Subject: Re: VRML: I want to open a new browser window (but I can't)
Date: Wed, 03 Dec 1997 12:55:36 -0600
Message-ID: <3485AB28.14E8@hiwaay.net>
Organization: http://hiwaay.net/~crispen/


Lourdes Guerra wrote:

>     I'm building a virtual world and I would want to open a new
> browser each time someone knocks on the door.
[snip]
>     How can I open a new window containing a new world through an
> event?

There are two ways.  One is with an Anchor node, and
use the parameter field with something like

	parameter "target=newpage"

Here's an example:

DEF JUKEBOX Transform {
  translation 0 0.74 -3.3
  children [
    Anchor {
      url "../../../midi/index.html"
      parameter "target=newpage"
      children [
        Inline {
          url "jukebox.wrl"
        }
      ]
    }
  ]
}


The other way is a little more complicated:

PROTO Button [
  field MFString buttonUrl [ ]
  field SFString buttonDescription ""
  field MFString buttonParameter "target=newpage"
]
{

... some geometry and a TouchSensor called
    BUTTON_TOUCHED

DEF BUTTON_SCRIPT Script {
  eventIn SFBool mimic_anchor
  eventIn SFBool show_description

  field MFString button_url IS buttonUrl
  field SFString button_description IS buttonDescription
  field MFString button_parameter IS buttonParameter

  url "javascript:
    function mimic_anchor(value) {
      if (value)
        Browser.loadURL(button_url, button_parameter);
    }
    function show_description(value) {
      if (value)
        Browser.setDescription(button_description);
      else
        Browser.setDescription('');
    }"
}

ROUTE BUTTON_TOUCHED.isOver TO BUTTON_SCRIPT.show_description
ROUTE BUTTON_TOUCHED.isActive TO BUTTON_SCRIPT.mimic_anchor
}

It's in a PROTO because it might turn out to be
generally useful to have in your world.  If you're
only going to use it once, you can just use the
Script and the ROUTEs and unwind the PROTO (e.g.,
replace "buttonDescription" with the string you
want to show, in quotes).

You can see this in action at
http://hiwaay.net/~crispen/worlds/cafe/2/cafe.wrl

Each of the buttons on the kiosk does this -- in
fact, it also does a little thing to move the
button and waits for you to let up on the mouse
button before it'll load the URL (that's to let you
see the button move).  All the kiosk buttons are
instances of one PROTO, as you can see from the
source code.

A somewhat smaller world, for bandwidth-limited
folks, is at
http://hiwaay.net/~crispen/worlds/test/conetree2.wrl
Read the code in the UrlBall PROTO.
--
Rev. Bob "Bob" Crispen
crispen@hiwaay.net
"What a day, what a day, for an auto-da-fe"
