i think you are trying to call the function whilst it's still not loaded yet (browsers behave differentely on applet loading, some load it synchronously while other don't).
it would be safer for you to check if the function exists before trying to call it , in case it doesn't , tell the browser to wait a few milli seconds .
here's a mock code for you:
var cameraViewer = document.getElementById('cameraViewer');
if (typeof(cameraViewer.listDevices) != "undefined") {
// safe to use the function
var deviceList = new Array(cameraViewer.listDevices());
}
else{
setTimeout(function() {
var deviceList = new Array(cameraViewer.listDevices());
}, 1000);
}