At least this is yielding me success in proportion to my effort, which is more than I can say for research lately.
Here is the latest result of my CPS-language-to-Javascript backend attempt: (which together with tom's front-and-middle-end basically constitutes a core-ML-to-Javascript compiler) It is now possible to write a glue function "install_function" such that running in Firefox the compilation of
let fun test (i) = let val x = alert(i) in 5 end in install_function("test", test) end
in fact creates a javascript function test, and if you call it from javascript-world with an argument, it will indeed pop up an alert window displaying that argument, and it will return 5 to javascript world. I'm not sure I've accounted fully for how closure conversion munges around calling conventions and stuff, but for the one-argument environment-ignoring case, it totally works. This means that one can (after some boilerplate is out of the way) basically write pure ML even for the higher-order parts of the DOM and user-interface APIs that require callbacks.