Module Js_of_ocaml__.Dom_html
CSS style declaration
class type cssStyleDeclaration = object ... endEvents
type (-'a, -'b) event_listener= ('a, 'b) Js_of_ocaml.Dom.event_listenerThe type of event listener functions. The first type parameter
'ais the type of the target object; the second parameter'bis the type of the event object.
class type event = object ... endand 'a customEvent = object ... endand focusEvent = object ... endand mouseEvent = object ... endand keyboardEvent = object ... endand mousewheelEvent = object ... endand mouseScrollEvent = object ... endand touchEvent = object ... endand touchList = object ... endand touch = object ... endand dragEvent = object ... endand dataTransfer = object ... endand eventTarget = object ... endCommon properties of event target objects:
onclick,onkeypress, ...
and popStateEvent = object ... endand pointerEvent = object ... endand storageEvent = object ... endand storage = object ... endStorage
and hashChangeEvent = object ... endand animationEvent = object ... endand mediaEvent = object ... endHTML elements
and nodeSelector = object ... endand tokenList = object ... endand element = object ... endProperties common to all HTML elements
and clientRect = object ... endRectangular box (used for element bounding boxes)
and clientRectList = object ... endclass type 'node collection = object ... endCollection of HTML elements
class type htmlElement = elementclass type headElement = object ... endclass type linkElement = object ... endclass type titleElement = object ... endclass type metaElement = object ... endclass type baseElement = object ... endclass type styleElement = object ... endclass type bodyElement = elementclass type formElement = object ... endclass type optGroupElement = object ... endclass type optionElement = object ... endclass type selectElement = object ... endclass type inputElement = object ... endclass type textAreaElement = object ... endclass type buttonElement = object ... endclass type labelElement = object ... endclass type fieldSetElement = object ... endclass type legendElement = object ... endclass type uListElement = elementclass type oListElement = elementclass type dListElement = elementclass type divElement = elementclass type paragraphElement = elementclass type headingElement = elementclass type quoteElement = object ... endclass type preElement = elementclass type modElement = object ... endclass type anchorElement = object ... endclass type imageElement = object ... endclass type objectElement = object ... endclass type paramElement = object ... endclass type areaElement = object ... endclass type mapElement = object ... endclass type scriptElement = object ... endclass type embedElement = object ... endclass type tableCellElement = object ... endclass type tableRowElement = object ... endclass type tableColElement = object ... endclass type tableSectionElement = object ... endclass type tableCaptionElement = elementclass type tableElement = object ... endclass type timeRanges = object ... endtype networkState=|NETWORK_EMPTY|NETWORK_IDLE|NETWORK_LOADING|NETWORK_NO_SOURCEtype readyState=|HAVE_NOTHING|HAVE_METADATA|HAVE_CURRENT_DATA|HAVE_FUTURE_DATA|HAVE_ENOUGH_DATA
class type mediaElement = object ... endclass type audioElement = object ... endclass type videoElement = object ... endCanvas object
val _2d_ : context
class type canvasElement = object ... endand canvasRenderingContext2D = object ... endand canvasGradient = object ... endand textMetrics = object ... endand imageData = object ... endand canvasPixelArray = object ... endval pixel_get : canvasPixelArray Js_of_ocaml.Js.t -> int -> intval pixel_set : canvasPixelArray Js_of_ocaml.Js.t -> int -> int -> unit
class type range = object ... endObject representing a range *
class type selection = object ... endInformation on current selection
Document objects
class type document = object ... endval document : document Js_of_ocaml.Js.tThe current document
val getElementById_opt : string -> element Js_of_ocaml.Js.t optiongetElementById_opt idreturns the element with the ididin the current document. It returnsNoneif there are no such element
val getElementById_exn : string -> element Js_of_ocaml.Js.tgetElementById_exn idreturns the element with the ididin 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 optiongetElementById_coerce id coercereturns the element with the ididin the current document and attempt to coerce it using the providedcoercefunction. It returnsNoneif there are no such element or if thecoercefunction returnsJs.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.tgetElementById idreturns the element with the ididin the current document. It raisesNot_foundif there are no such element
Window objects
class type location = object ... endLocation information
val location_origin : location Js_of_ocaml.Js.t -> Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t
class type history = object ... endBrowser history information
class type undoManager = object ... endUndo manager
Navigator information
class type screen = object ... endclass type applicationCache = object ... endclass type _URL = object ... endclass type window = object ... endSpecification of window objects
val window : window Js_of_ocaml.Js.tThe current window
class type frameSetElement = object ... endclass type frameElement = object ... endclass type iFrameElement = object ... endEvent handlers
val no_handler : ('a, 'b) event_listenersee
Dom.no_handler
val handler : (event Js_of_ocaml.Js.t as 'b -> bool Js_of_ocaml.Js.t) -> ('a, 'b) event_listenersee
Dom.handler
val full_handler : ('a -> event Js_of_ocaml.Js.t as 'b -> bool Js_of_ocaml.Js.t) -> ('a, 'b) event_listenersee
Dom.full_handler
val invoke_handler : ('a, 'b) event_listener -> 'a -> 'b -> bool Js_of_ocaml.Js.tsee
Dom.invoke_handler
val eventTarget : event Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tsee
Dom.eventTarget
val eventRelatedTarget : mouseEvent Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.t Js_of_ocaml.Js.optReturns this event related target.
module Event : sig ... endEvent types:
mousedown,keypress, ...
type event_listener_id= Js_of_ocaml.Dom.event_listener_id
val addEventListenerWithOptions : eventTarget Js_of_ocaml.Js.t as 'a -> 'b Event.typ -> ?capture:bool Js_of_ocaml.Js.t -> ?once:bool Js_of_ocaml.Js.t -> ?passive:bool Js_of_ocaml.Js.t -> ('a, 'b) event_listener -> event_listener_idAdd an event listener. This function matches the option-object variant of the
addEventListenerDOM method, except that it returns an id for removing the listener.
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_idAdd an event listener. This function matches the useCapture boolean variant of the
addEventListenerDOM method, except that it returns an id for removing the listener.
val removeEventListener : event_listener_id -> unitRemove the given event listener.
val addMousewheelEventListenerWithOptions : eventTarget Js_of_ocaml.Js.t as 'a -> ?capture:bool Js_of_ocaml.Js.t -> ?once:bool Js_of_ocaml.Js.t -> ?passive:bool Js_of_ocaml.Js.t -> (mouseEvent Js_of_ocaml.Js.t -> dx:int -> dy:int -> bool Js_of_ocaml.Js.t) -> event_listener_idAdd a mousewheel event listener with option-object variant of the
addEventListenerDOM method. The callback is provided the event and the numbers of ticks the mouse wheel moved. Positive means down / right.
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_idAdd a mousewheel event listener with the useCapture boolean variant of the
addEventListenerDOM method. The callback is provided the event and the numbers of ticks the mouse wheel moved. Positive means down / right.
val createCustomEvent : ?bubbles:bool -> ?cancelable:bool -> ?detail:'a -> 'a customEvent Js_of_ocaml.Js.t Event.typ -> 'a customEvent Js_of_ocaml.Js.tSee
Dom.createCustomEvent
Mouse event helper functions
val buttonPressed : mouseEvent Js_of_ocaml.Js.t -> mouse_button
Position helper functions
val eventAbsolutePosition : mouseEvent Js_of_ocaml.Js.t -> int * intReturns the absolute position of the mouse pointer.
val elementClientPosition : element Js_of_ocaml.Js.t -> int * intPosition of an element relative to the viewport
Key event helper functions
module Keyboard_code : sig ... endUse
Keyboard_codewhen 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 ... endUse
Keyboard_keywhen 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
val createHtml : document Js_of_ocaml.Js.t -> htmlElement Js_of_ocaml.Js.tval createHead : document Js_of_ocaml.Js.t -> headElement Js_of_ocaml.Js.tval createLink : document Js_of_ocaml.Js.t -> linkElement Js_of_ocaml.Js.tval createTitle : document Js_of_ocaml.Js.t -> titleElement Js_of_ocaml.Js.tval createMeta : document Js_of_ocaml.Js.t -> metaElement Js_of_ocaml.Js.tval createBase : document Js_of_ocaml.Js.t -> baseElement Js_of_ocaml.Js.tval createStyle : document Js_of_ocaml.Js.t -> styleElement Js_of_ocaml.Js.tval createBody : document Js_of_ocaml.Js.t -> bodyElement Js_of_ocaml.Js.tval createForm : document Js_of_ocaml.Js.t -> formElement Js_of_ocaml.Js.tval createOptgroup : document Js_of_ocaml.Js.t -> optGroupElement Js_of_ocaml.Js.tval createOption : document Js_of_ocaml.Js.t -> optionElement Js_of_ocaml.Js.tval createSelect : ?_type:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> ?name:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> document Js_of_ocaml.Js.t -> selectElement Js_of_ocaml.Js.tval createInput : ?_type:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> ?name:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> document Js_of_ocaml.Js.t -> inputElement Js_of_ocaml.Js.tval createTextarea : ?_type:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> ?name:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> document Js_of_ocaml.Js.t -> textAreaElement Js_of_ocaml.Js.tval createButton : ?_type:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> ?name:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t -> document Js_of_ocaml.Js.t -> buttonElement Js_of_ocaml.Js.tval createLabel : document Js_of_ocaml.Js.t -> labelElement Js_of_ocaml.Js.tval createFieldset : document Js_of_ocaml.Js.t -> fieldSetElement Js_of_ocaml.Js.tval createLegend : document Js_of_ocaml.Js.t -> legendElement Js_of_ocaml.Js.tval createUl : document Js_of_ocaml.Js.t -> uListElement Js_of_ocaml.Js.tval createOl : document Js_of_ocaml.Js.t -> oListElement Js_of_ocaml.Js.tval createDl : document Js_of_ocaml.Js.t -> dListElement Js_of_ocaml.Js.tval createLi : document Js_of_ocaml.Js.t -> liElement Js_of_ocaml.Js.tval createDiv : document Js_of_ocaml.Js.t -> divElement Js_of_ocaml.Js.tval createEmbed : document Js_of_ocaml.Js.t -> embedElement Js_of_ocaml.Js.tval createP : document Js_of_ocaml.Js.t -> paragraphElement Js_of_ocaml.Js.tval createH1 : document Js_of_ocaml.Js.t -> headingElement Js_of_ocaml.Js.tval createH2 : document Js_of_ocaml.Js.t -> headingElement Js_of_ocaml.Js.tval createH3 : document Js_of_ocaml.Js.t -> headingElement Js_of_ocaml.Js.tval createH4 : document Js_of_ocaml.Js.t -> headingElement Js_of_ocaml.Js.tval createH5 : document Js_of_ocaml.Js.t -> headingElement Js_of_ocaml.Js.tval createH6 : document Js_of_ocaml.Js.t -> headingElement Js_of_ocaml.Js.tval createQ : document Js_of_ocaml.Js.t -> quoteElement Js_of_ocaml.Js.tval createBlockquote : document Js_of_ocaml.Js.t -> quoteElement Js_of_ocaml.Js.tval createPre : document Js_of_ocaml.Js.t -> preElement Js_of_ocaml.Js.tval createBr : document Js_of_ocaml.Js.t -> brElement Js_of_ocaml.Js.tval createHr : document Js_of_ocaml.Js.t -> hrElement Js_of_ocaml.Js.tval createIns : document Js_of_ocaml.Js.t -> modElement Js_of_ocaml.Js.tval createDel : document Js_of_ocaml.Js.t -> modElement Js_of_ocaml.Js.tval createA : document Js_of_ocaml.Js.t -> anchorElement Js_of_ocaml.Js.tval createImg : document Js_of_ocaml.Js.t -> imageElement Js_of_ocaml.Js.tval createObject : document Js_of_ocaml.Js.t -> objectElement Js_of_ocaml.Js.tval createParam : document Js_of_ocaml.Js.t -> paramElement Js_of_ocaml.Js.tval createMap : document Js_of_ocaml.Js.t -> mapElement Js_of_ocaml.Js.tval createArea : document Js_of_ocaml.Js.t -> areaElement Js_of_ocaml.Js.tval createScript : document Js_of_ocaml.Js.t -> scriptElement Js_of_ocaml.Js.tval createTable : document Js_of_ocaml.Js.t -> tableElement Js_of_ocaml.Js.tval createCaption : document Js_of_ocaml.Js.t -> tableCaptionElement Js_of_ocaml.Js.tval createCol : document Js_of_ocaml.Js.t -> tableColElement Js_of_ocaml.Js.tval createColgroup : document Js_of_ocaml.Js.t -> tableColElement Js_of_ocaml.Js.tval createThead : document Js_of_ocaml.Js.t -> tableSectionElement Js_of_ocaml.Js.tval createTfoot : document Js_of_ocaml.Js.t -> tableSectionElement Js_of_ocaml.Js.tval createTbody : document Js_of_ocaml.Js.t -> tableSectionElement Js_of_ocaml.Js.tval createTr : document Js_of_ocaml.Js.t -> tableRowElement Js_of_ocaml.Js.tval createTh : document Js_of_ocaml.Js.t -> tableCellElement Js_of_ocaml.Js.tval createTd : document Js_of_ocaml.Js.t -> tableCellElement Js_of_ocaml.Js.tval createSub : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createSup : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createSpan : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createTt : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createI : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createB : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createBig : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createSmall : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createEm : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createStrong : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createCite : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createDfn : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createCode : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createSamp : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createKbd : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createVar : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createAbbr : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createDd : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createDt : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createNoscript : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createAddress : document Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tval createFrameset : document Js_of_ocaml.Js.t -> frameSetElement Js_of_ocaml.Js.tval createFrame : document Js_of_ocaml.Js.t -> frameElement Js_of_ocaml.Js.tval createIframe : document Js_of_ocaml.Js.t -> iFrameElement Js_of_ocaml.Js.tval createAudio : document Js_of_ocaml.Js.t -> audioElement Js_of_ocaml.Js.tval createVideo : document Js_of_ocaml.Js.t -> videoElement Js_of_ocaml.Js.t
val createCanvas : document Js_of_ocaml.Js.t -> canvasElement Js_of_ocaml.Js.t- raises Canvas_not_available
when canvas elements are not supported by the browser.
Coercion functions
val element : Js_of_ocaml__.Dom.#element Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.tCoercion from a general DOM element to an HTML element. (Unsafe in general.)
type taggedElement=
val tagged : element Js_of_ocaml.Js.t -> taggedElementval opt_tagged : element Js_of_ocaml.Js.t Js_of_ocaml.Js.opt -> taggedElement option
type taggedEvent=|MouseEvent of mouseEvent Js_of_ocaml.Js.t|KeyboardEvent of keyboardEvent Js_of_ocaml.Js.t|MousewheelEvent of mousewheelEvent Js_of_ocaml.Js.t|MouseScrollEvent of mouseScrollEvent Js_of_ocaml.Js.t|PopStateEvent of popStateEvent Js_of_ocaml.Js.t|OtherEvent of event Js_of_ocaml.Js.t
val taggedEvent : event Js_of_ocaml.Js.t -> taggedEventval opt_taggedEvent : event Js_of_ocaml.Js.t Js_of_ocaml.Js.opt -> taggedEvent optionval stopPropagation : event Js_of_ocaml.Js.t -> unit
module CoerceTo : sig ... endval setTimeout : (unit -> unit) -> float -> timeout_id_safeSame as
Dom_html.window##setTimeout cb msbut prevents overflow with delay greater than 24 days.
val clearTimeout : timeout_id_safe -> unitval js_array_of_collection : element collection Js_of_ocaml.Js.t -> element Js_of_ocaml.Js.t Js_of_ocaml.Js.js_array Js_of_ocaml.Js.tConvert a
Dom_html.collectionto a Js array
Deprecated function.
val _requestAnimationFrame : (unit -> unit) Js_of_ocaml.Js.callback -> unitCall the appropriate
requestAnimationFramemethod 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.