Skip to content

Instantly share code, notes, and snippets.

@yoshihiro503
Created August 21, 2012 00:16
Show Gist options
  • Save yoshihiro503/3409658 to your computer and use it in GitHub Desktop.
Save yoshihiro503/3409658 to your computer and use it in GitHub Desktop.
js_of_ocamlでボタンを追加するサンプル
let document = Dom_html.document;;
let window = Dom_html.window;;
let b = Dom_html.createInput ~_type:(Js.string "button") document;;
b##value <- Js.string "Push Me";;
b##onclick <- Dom_html.handler (fun _ -> window##alert(Js.string "hello"); Js._true);;
let top = Js.Opt.get (document##getElementById(Js.string "toplevel")) (fun () -> assert false);;
Dom.appendChild top b;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment