I don't know about getDocumentBase(), but here's some JavaScript that does the trick:
Code:<script type="text/javascript" charset="utf-8">
var pgArgs = new Object();
function getPageArgs() {
var argElems = window.location.search.substring(1).split("&");
for (i=0; i < argElems.length; i++) {
var elem = argElems[i].split("=");
pgArgs[elem[0]] = unescape(elem[1]);
}
}
getPageArgs()
</script>
(I probably pinched this code from somewhere, but I don't have any notes about its origin. If anyone reading this is the original author, please let me know and I'll be sure to credit you.)
Insert the above sometime before your page finishes loading and before you need the parameters. I simply insert it near the top of the HTML's
<head> section. Then, where you need to pass your parameter to the applet, insert:
Code:<script type="text/javascript" charset="utf-8">
document.write('<param name="paramID" value="' + pgArgs["urlParamID"] + '">');
</script>
(or the equivalent syntax for the applet embedding method you choose). This will allow you to use a URL of the form:
http://www.example.com/processingsketch.html?urlParamID=value
and pass the parameter's "value" to your sketch.
Does that make sense? This seems to work pretty well on the few browsers where I've tested. Can anyone with more JavaScript experience suggest a better way?