| Steve Smith 2006-04-21, 7:13 pm |
| I'm trying to get contact 5.3 to call a script in a html document without
success
Can anyone send me a working example ?
Thanks
Steve Smith
This how its described in the sdk
3. Calling JavaScript from VRML:
Here when the touchTime event occurs, set_string is called in the
script node. The Script method OnEvent() will be called with the specified
parameters.
Of course par1 and par2 can be replaced at runtime by actual parameters.
DEF RotationScript Script {
field MFString newurl [ "OnEvent( par1, par2 )" ]
field MFString param [ "" "" ]
eventIn SFTime clicked
eventIn SFTime set_string
eventOut SFRotation rotation_changed
url "vrmlscript:
function clicked (value, time) {
angle = Math.random()*6.283;
rotation_changed = new SFRotation(0,1,0,angle);
}
function set_string (value, time) {
Browser.loadURL(newurl,param);
}
"
}
ROUTE RotSensor.touchTime TO RotationScript.set_stringand the HTML
definition:<SCRIPT language=Javascript>function OnEvent(par1, par2, time)
{ document.sform.sfield.value = par1 + par2 + time; }</SCRIPT>
|