package js_of_ocaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
  • deprecated Will be removed past 2019-01-01. Use Js_of_ocaml.Dom_html instead.

CSS style declaration

class type cssStyleDeclaration = object ... end

Events

type (-'a, -'b) event_listener = ('a, 'b) Js_of_ocaml.Dom.event_listener

The type of event listener functions. The first type parameter 'a is the type of the target object; the second parameter 'b is the type of the event object.

type mouse_button =
  1. | No_button
  2. | Left_button
  3. | Middle_button
  4. | Right_button
class type event = object ... end
class type mouseEvent = object ... end
class type keyboardEvent = object ... end
class type mousewheelEvent = object ... end
class type mouseScrollEvent = object ... end
class type touchEvent = object ... end
class type touchList = object ... end
class type touch = object ... end
class type dragEvent = object ... end
class type dataTransfer = object ... end
class type eventTarget = object ... end

Common properties of event target objects: onclick, onkeypress, ...

class type popStateEvent = object ... end
class type storageEvent = object ... end
class type storage = object ... end

Storage

class type hashChangeEvent = object ... end
class type animationEvent = object ... end
class type mediaEvent = object ... end

HTML elements

class type nodeSelector = object ... end
class type tokenList = object ... end
class type element = object ... end

Properties common to all HTML elements

class type clientRect = object ... end

Rectangular box (used for element bounding boxes)

class type clientRectList = object ... end
class type 'node collection = object ... end

Collection of HTML elements

class type htmlElement = element
class type headElement = object ... end
class type linkElement = object ... end
class type titleElement = object ... end
class type metaElement = object ... end
class type baseElement = object ... end
class type styleElement = object ... end
class type bodyElement = element
class type formElement = object ... end
class type optGroupElement = object ... end
class type optionElement = object ... end
class type selectElement = object ... end
class type inputElement = object ... end
class type textAreaElement = object ... end
class type buttonElement = object ... end
class type labelElement = object ... end
class type fieldSetElement = object ... end
class type legendElement = object ... end
class type uListElement = element
class type oListElement = element
class type dListElement = element
class type liElement = element
class type divElement = element
class type headingElement = element
class type quoteElement = object ... end
class type preElement = element
class type brElement = element
class type hrElement = element
class type modElement = object ... end
class type anchorElement = object ... end
class type imageElement = object ... end
class type objectElement = object ... end
class type paramElement = object ... end
class type areaElement = object ... end
class type mapElement = object ... end
class type scriptElement = object ... end
class type embedElement = object ... end
class type tableCellElement = object ... end
class type tableRowElement = object ... end
class type tableColElement = object ... end
class type tableSectionElement = object ... end
class type tableElement = object ... end
class type timeRanges = object ... end
type networkState =
  1. | NETWORK_EMPTY
  2. | NETWORK_IDLE
  3. | NETWORK_LOADING
  4. | NETWORK_NO_SOURCE
type readyState =
  1. | HAVE_NOTHING
  2. | HAVE_METADATA
  3. | HAVE_CURRENT_DATA
  4. | HAVE_FUTURE_DATA
  5. | HAVE_ENOUGH_DATA
class type mediaElement = object ... end
class type audioElement = object ... end
class type videoElement = object ... end

Canvas object

type context
val _2d_ : context
type canvasPattern
class type canvasElement = object ... end
class type canvasRenderingContext2D = object ... end
class type canvasGradient = object ... end
class type textMetrics = object ... end
class type imageData = object ... end
class type canvasPixelArray = object ... end
val pixel_get : canvasPixelArray Js_of_ocaml.Js.t -> int -> int
val pixel_set : canvasPixelArray Js_of_ocaml.Js.t -> int -> int -> unit
class type range = object ... end

Object representing a range *

class type selection = object ... end

Information on current selection

Document objects

class type document = object ... end
val document : document Js_of_ocaml.Js.t

The current document

val getElementById_opt : string -> element Js_of_ocaml.Js.t option

getElementById_opt id returns the element with the id id in the current document. It returns None if there are no such element

val getElementById_exn : string -> element Js_of_ocaml.Js.t

getElementById_exn id returns the element with the id id in the current document. It raises if there are no such element

val getElementById_coerce : string -> (element Js_of_ocaml.Js.t -> 'a Js_of_ocaml.Js.opt) -> 'a option

getElementById_coerce id coerce returns the element with the id id in the current document and attempt to coerce it using the provided coerce function. It returns None if there are no such element or if the coerce function returns Js.none. Typical usage is the following:

match Dom_html.getElementById_coerce "myinput" Dom_html.CoerceTo.input with
| None -> ..
| Some input -> ..
val getElementById : string -> element Js_of_ocaml.Js.t

getElementById id returns the element with the id id in the current document. It raises Not_found if there are no such element

Window objects

class type location = object ... end

Location information

class type history = object ... end

Browser history information

class type undoManager = object ... end

Undo manager

class type navigator = object ... end

Navigator information

class type screen = object ... end
class type applicationCache = object ... end
type interval_id
type timeout_id
type animation_frame_request_id
class type _URL = object ... end
class type window = object ... end

Specification of window objects

The current window

class type frameSetElement = object ... end
class type frameElement = object ... end
class type iFrameElement = object ... end

Event handlers

val no_handler : ('a, 'b) event_listener

see Dom.no_handler

val handler : (event Js_of_ocaml.Js.t as 'b -> bool Js_of_ocaml.Js.t) -> ('a, 'b) event_listener

see Dom.handler

val full_handler : ('a -> event Js_of_ocaml.Js.t as 'b -> bool Js_of_ocaml.Js.t) -> ('a, 'b) event_listener

see Dom.full_handler

val invoke_handler : ('a, 'b) event_listener -> 'a -> 'b -> bool Js_of_ocaml.Js.t

see Dom.invoke_handler

see Dom.eventTarget

Returns this event related target.

module Event : sig ... end

Event types: mousedown, keypress, ...

type event_listener_id = Js_of_ocaml.Dom.event_listener_id
val addEventListener : eventTarget Js_of_ocaml.Js.t as 'a -> 'b Event.typ -> ('a, 'b) event_listener -> bool Js_of_ocaml.Js.t -> event_listener_id

Add an event listener. This function matches the addEventListener DOM method, except that it returns an id for removing the listener.

val removeEventListener : event_listener_id -> unit

Remove the given event listener.

val addMousewheelEventListener : eventTarget Js_of_ocaml.Js.t as 'a -> (mouseEvent Js_of_ocaml.Js.t -> dx:int -> dy:int -> bool Js_of_ocaml.Js.t) -> bool Js_of_ocaml.Js.t -> event_listener_id

Add a mousewheel event listener. The callback is provided the event and the numbers of ticks the mouse wheel moved. Positive means down / right.

Mouse event helper functions

Position helper functions

val eventAbsolutePosition : mouseEvent Js_of_ocaml.Js.t -> int * int

Returns the absolute position of the mouse pointer.

val elementClientPosition : element Js_of_ocaml.Js.t -> int * int

Position of an element relative to the viewport

val getDocumentScroll : unit -> int * int

Viewport top/left position

Key event helper functions

module Keyboard_code : sig ... end

Use Keyboard_code when you want to identify a key that the user pressed. This should be invoked for keydown and keyup events, not keypress events.

module Keyboard_key : sig ... end

Use Keyboard_key when you want to identify the character that the user typed. This should only be invoked on keypress events, not keydown or keyup events.

Helper functions for creating HTML elements

exception Canvas_not_available

Coercion functions

Coercion from a general DOM element to an HTML element. (Unsafe in general.)

type taggedElement =
  1. | A of anchorElement Js_of_ocaml.Js.t
  2. | Area of areaElement Js_of_ocaml.Js.t
  3. | Audio of audioElement Js_of_ocaml.Js.t
  4. | Base of baseElement Js_of_ocaml.Js.t
  5. | Blockquote of quoteElement Js_of_ocaml.Js.t
  6. | Body of bodyElement Js_of_ocaml.Js.t
  7. | Br of brElement Js_of_ocaml.Js.t
  8. | Button of buttonElement Js_of_ocaml.Js.t
  9. | Canvas of canvasElement Js_of_ocaml.Js.t
  10. | Caption of tableCaptionElement Js_of_ocaml.Js.t
  11. | Col of tableColElement Js_of_ocaml.Js.t
  12. | Colgroup of tableColElement Js_of_ocaml.Js.t
  13. | Del of modElement Js_of_ocaml.Js.t
  14. | Div of divElement Js_of_ocaml.Js.t
  15. | Dl of dListElement Js_of_ocaml.Js.t
  16. | Embed of embedElement Js_of_ocaml.Js.t
  17. | Fieldset of fieldSetElement Js_of_ocaml.Js.t
  18. | Form of formElement Js_of_ocaml.Js.t
  19. | Frameset of frameSetElement Js_of_ocaml.Js.t
  20. | Frame of frameElement Js_of_ocaml.Js.t
  21. | H1 of headingElement Js_of_ocaml.Js.t
  22. | H2 of headingElement Js_of_ocaml.Js.t
  23. | H3 of headingElement Js_of_ocaml.Js.t
  24. | H4 of headingElement Js_of_ocaml.Js.t
  25. | H5 of headingElement Js_of_ocaml.Js.t
  26. | H6 of headingElement Js_of_ocaml.Js.t
  27. | Head of headElement Js_of_ocaml.Js.t
  28. | Hr of hrElement Js_of_ocaml.Js.t
  29. | Html of htmlElement Js_of_ocaml.Js.t
  30. | Iframe of iFrameElement Js_of_ocaml.Js.t
  31. | Img of imageElement Js_of_ocaml.Js.t
  32. | Input of inputElement Js_of_ocaml.Js.t
  33. | Ins of modElement Js_of_ocaml.Js.t
  34. | Label of labelElement Js_of_ocaml.Js.t
  35. | Legend of legendElement Js_of_ocaml.Js.t
  36. | Li of liElement Js_of_ocaml.Js.t
  37. | Map of mapElement Js_of_ocaml.Js.t
  38. | Meta of metaElement Js_of_ocaml.Js.t
  39. | Object of objectElement Js_of_ocaml.Js.t
  40. | Ol of oListElement Js_of_ocaml.Js.t
  41. | Optgroup of optGroupElement Js_of_ocaml.Js.t
  42. | Option of optionElement Js_of_ocaml.Js.t
  43. | P of paramElement Js_of_ocaml.Js.t
  44. | Param of paramElement Js_of_ocaml.Js.t
  45. | Pre of preElement Js_of_ocaml.Js.t
  46. | Q of quoteElement Js_of_ocaml.Js.t
  47. | Script of scriptElement Js_of_ocaml.Js.t
  48. | Select of selectElement Js_of_ocaml.Js.t
  49. | Style of styleElement Js_of_ocaml.Js.t
  50. | Table of tableElement Js_of_ocaml.Js.t
  51. | Tbody of tableSectionElement Js_of_ocaml.Js.t
  52. | Td of tableCellElement Js_of_ocaml.Js.t
  53. | Textarea of textAreaElement Js_of_ocaml.Js.t
  54. | Tfoot of tableSectionElement Js_of_ocaml.Js.t
  55. | Th of tableCellElement Js_of_ocaml.Js.t
  56. | Thead of tableSectionElement Js_of_ocaml.Js.t
  57. | Title of titleElement Js_of_ocaml.Js.t
  58. | Tr of tableRowElement Js_of_ocaml.Js.t
  59. | Ul of uListElement Js_of_ocaml.Js.t
  60. | Video of videoElement Js_of_ocaml.Js.t
  61. | Other of element Js_of_ocaml.Js.t
type taggedEvent =
  1. | MouseEvent of mouseEvent Js_of_ocaml.Js.t
  2. | KeyboardEvent of keyboardEvent Js_of_ocaml.Js.t
  3. | MousewheelEvent of mousewheelEvent Js_of_ocaml.Js.t
  4. | MouseScrollEvent of mouseScrollEvent Js_of_ocaml.Js.t
  5. | PopStateEvent of popStateEvent Js_of_ocaml.Js.t
  6. | OtherEvent of event Js_of_ocaml.Js.t
val taggedEvent : event Js_of_ocaml.Js.t -> taggedEvent
val opt_taggedEvent : event Js_of_ocaml.Js.t Js_of_ocaml.Js.opt -> taggedEvent option
val stopPropagation : event Js_of_ocaml.Js.t -> unit
module CoerceTo : sig ... end

HTMLElement

type timeout_id_safe
val setTimeout : (unit -> unit) -> float -> timeout_id_safe

Same as Dom_html.window##setTimeout cb ms but prevents overflow with delay greater than 24 days.

val clearTimeout : timeout_id_safe -> unit

Convert a Dom_html.collection to a Js array

Deprecated function.

val _requestAnimationFrame : (unit -> unit) Js_of_ocaml.Js.callback -> unit

Call the appropriate requestAnimationFrame method variant (depending on the navigator), or sleep for a short amount of time when there no such method is provided. We currently prefix the function name with as underscore as the interface of this function is not completely standardized yet. Thus, we leave the room to a function with a possibly refined type.

This function is deprecated. Use the requestAnimationFrame of the window object instead.

OCaml

Innovation. Community. Security.