Js_of_ocaml.Dom_htmlDOM HTML binding
This is a partial binding to the DOM HTML API.
class type cssStyleDeclaration = object ... endtype (-'a, -'b) event_listener = ('a, 'b) Dom.event_listenerThe 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.
class type event = object ... endclass type 'a customEvent = object ... endclass type focusEvent = object ... endclass type mouseEvent = object ... endclass type keyboardEvent = object ... endclass type wheelEvent = object ... endclass type mousewheelEvent = wheelEventclass type mouseScrollEvent = object ... endclass type touchEvent = object ... endclass type touchList = object ... endclass type touch = object ... endclass type submitEvent = object ... endclass type dragEvent = object ... endclass type clipboardEvent = object ... endclass type toggleEvent = object ... endclass type mediaQueryListEvent = object ... endclass type dataTransfer = object ... endclass type eventTarget = object ... endCommon properties of event target objects: onclick, onkeypress, ...
class type popStateEvent = object ... endclass type pointerEvent = object ... endclass type storageEvent = object ... endclass type storage = object ... endStorage
class type hashChangeEvent = object ... endclass type animationEvent = object ... endclass type transitionEvent = object ... endclass type mediaEvent = object ... endclass type messageEvent = object ... endclass type nodeSelector = object ... endclass type tokenList = object ... endclass type element = object ... endProperties common to all HTML elements
class type clientRect = object ... endRectangular box (used for element bounding boxes)
class type 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 dialogElement = object ... endclass 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 detailsElement = 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 ... endclass type mediaElement = object ... endclass type audioElement = object ... endclass type videoElement = object ... endval _2d_ : contextclass type canvasElement = object ... endclass type canvasRenderingContext2D = object ... endclass type canvasGradient = object ... endclass type textMetrics = object ... endclass type imageData = object ... endclass type canvasPixelArray = object ... endval pixel_get : canvasPixelArray Js.t -> int -> intval pixel_set : canvasPixelArray Js.t -> int -> int -> unitclass type range = object ... endObject representing a range *
class type selection = object ... endInformation on current selection
class type document = object ... endgetElementById_opt id returns the element with the id id in the current document. It returns None if there are no such element
getElementById_exn id returns the element with the id id in the current document. It raises if there are no such element
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 -> ..getElementById id returns the element with the id id in the current document. It raises Not_found if there are no such element
class type location = object ... endLocation information
val location_origin : location Js.t -> Js.js_string Js.tclass 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 mediaQueryList = object ... endclass type window = object ... endSpecification of window objects
class type frameSetElement = object ... endclass type frameElement = object ... endclass type iFrameElement = object ... endval no_handler : ('a, 'b) event_listenersee Dom.no_handler
val handler : ((event Js.t as 'b) -> bool Js.t) -> ('a, 'b) event_listenersee Dom.handler
val full_handler :
('a -> (event Js.t as 'b) -> bool Js.t) ->
('a, 'b) event_listenersee Dom.full_handler
val invoke_handler : ('a, 'b) event_listener -> 'a -> 'b -> bool Js.tsee Dom.invoke_handler
val eventRelatedTarget : mouseEvent Js.t -> element Js.t Js.optReturns this event related target.
module Event : sig ... endEvent types: mousedown, keypress, ...
type event_listener_id = Dom.event_listener_idval addEventListenerWithOptions :
(eventTarget Js.t as 'a) ->
'b Event.typ ->
?capture:bool Js.t ->
?once:bool Js.t ->
?passive:bool Js.t ->
('a, 'b) event_listener ->
event_listener_idAdd an event listener. This function matches the option-object variant of the addEventListener DOM method, except that it returns an id for removing the listener.
val addEventListener :
(eventTarget Js.t as 'a) ->
'b Event.typ ->
('a, 'b) event_listener ->
bool Js.t ->
event_listener_idAdd an event listener. This function matches the useCapture boolean variant of the addEventListener DOM 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.t ->
?capture:bool Js.t ->
?once:bool Js.t ->
?passive:bool Js.t ->
(mouseEvent Js.t -> dx:int -> dy:int -> bool Js.t) ->
event_listener_idAdd a wheel event listener with option-object variant of the addEventListener DOM method. The callback is provided the event and the numbers of ticks the mouse wheel moved. Positive means down / right.
val addMousewheelEventListener :
eventTarget Js.t ->
(mouseEvent Js.t -> dx:int -> dy:int -> bool Js.t) ->
bool Js.t ->
event_listener_idAdd a wheel event listener with the useCapture boolean variant of the addEventListener DOM 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.t Event.typ ->
'a customEvent Js.tSee Dom.createCustomEvent
val buttonPressed : mouseEvent Js.t -> mouse_buttonval eventAbsolutePosition : mouseEvent Js.t -> float * floatReturns the absolute position of the mouse pointer.
Position of an element relative to the viewport
module Keyboard_code : sig ... endUse 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 ... endUse 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.
val createHtml : document Js.t -> htmlElement Js.tval createHead : document Js.t -> headElement Js.tval createLink : document Js.t -> linkElement Js.tval createTitle : document Js.t -> titleElement Js.tval createMeta : document Js.t -> metaElement Js.tval createBase : document Js.t -> baseElement Js.tval createStyle : document Js.t -> styleElement Js.tval createBody : document Js.t -> bodyElement Js.tval createForm : document Js.t -> formElement Js.tval createOptgroup : document Js.t -> optGroupElement Js.tval createOption : document Js.t -> optionElement Js.tval createSelect :
?_type:Js.js_string Js.t ->
?name:Js.js_string Js.t ->
document Js.t ->
selectElement Js.tval createInput :
?_type:Js.js_string Js.t ->
?name:Js.js_string Js.t ->
document Js.t ->
inputElement Js.tval createTextarea :
?_type:Js.js_string Js.t ->
?name:Js.js_string Js.t ->
document Js.t ->
textAreaElement Js.tval createButton :
?_type:Js.js_string Js.t ->
?name:Js.js_string Js.t ->
document Js.t ->
buttonElement Js.tval createLabel : document Js.t -> labelElement Js.tval createFieldset : document Js.t -> fieldSetElement Js.tval createLegend : document Js.t -> legendElement Js.tval createUl : document Js.t -> uListElement Js.tval createOl : document Js.t -> oListElement Js.tval createDl : document Js.t -> dListElement Js.tval createDialog : document Js.t -> dialogElement Js.tval createDiv : document Js.t -> divElement Js.tval createEmbed : document Js.t -> embedElement Js.tval createP : document Js.t -> paragraphElement Js.tval createH1 : document Js.t -> headingElement Js.tval createH2 : document Js.t -> headingElement Js.tval createH3 : document Js.t -> headingElement Js.tval createH4 : document Js.t -> headingElement Js.tval createH5 : document Js.t -> headingElement Js.tval createH6 : document Js.t -> headingElement Js.tval createQ : document Js.t -> quoteElement Js.tval createBlockquote : document Js.t -> quoteElement Js.tval createPre : document Js.t -> preElement Js.tval createIns : document Js.t -> modElement Js.tval createDel : document Js.t -> modElement Js.tval createA : document Js.t -> anchorElement Js.tval createImg : document Js.t -> imageElement Js.tval createObject : document Js.t -> objectElement Js.tval createParam : document Js.t -> paramElement Js.tval createMap : document Js.t -> mapElement Js.tval createArea : document Js.t -> areaElement Js.tval createScript : document Js.t -> scriptElement Js.tval createTable : document Js.t -> tableElement Js.tval createCaption : document Js.t -> tableCaptionElement Js.tval createCol : document Js.t -> tableColElement Js.tval createColgroup : document Js.t -> tableColElement Js.tval createThead : document Js.t -> tableSectionElement Js.tval createTfoot : document Js.t -> tableSectionElement Js.tval createTbody : document Js.t -> tableSectionElement Js.tval createTr : document Js.t -> tableRowElement Js.tval createTh : document Js.t -> tableCellElement Js.tval createTd : document Js.t -> tableCellElement Js.tval createFrameset : document Js.t -> frameSetElement Js.tval createFrame : document Js.t -> frameElement Js.tval createIframe : document Js.t -> iFrameElement Js.tval createAudio : document Js.t -> audioElement Js.tval createVideo : document Js.t -> videoElement Js.tval createCanvas : document Js.t -> canvasElement Js.tval element : Dom.element Js.t -> element Js.tCoercion from a general DOM element to an HTML element. (Unsafe in general.)
type taggedElement = | A of anchorElement Js.t| Area of areaElement Js.t| Audio of audioElement Js.t| Base of baseElement Js.t| Blockquote of quoteElement Js.t| Body of bodyElement Js.t| Br of brElement Js.t| Button of buttonElement Js.t| Canvas of canvasElement Js.t| Caption of tableCaptionElement Js.t| Col of tableColElement Js.t| Colgroup of tableColElement Js.t| Del of modElement Js.t| Dialog of dialogElement Js.t| Div of divElement Js.t| Dl of dListElement Js.t| Embed of embedElement Js.t| Fieldset of fieldSetElement Js.t| Form of formElement Js.t| Frameset of frameSetElement Js.t| Frame of frameElement Js.t| H1 of headingElement Js.t| H2 of headingElement Js.t| H3 of headingElement Js.t| H4 of headingElement Js.t| H5 of headingElement Js.t| H6 of headingElement Js.t| Head of headElement Js.t| Hr of hrElement Js.t| Html of htmlElement Js.t| Iframe of iFrameElement Js.t| Img of imageElement Js.t| Input of inputElement Js.t| Ins of modElement Js.t| Label of labelElement Js.t| Legend of legendElement Js.t| Li of liElement Js.t| Link of linkElement Js.t| Map of mapElement Js.t| Meta of metaElement Js.t| Object of objectElement Js.t| Ol of oListElement Js.t| Optgroup of optGroupElement Js.t| Option of optionElement Js.t| P of paragraphElement Js.t| Param of paramElement Js.t| Pre of preElement Js.t| Q of quoteElement Js.t| Script of scriptElement Js.t| Select of selectElement Js.t| Style of styleElement Js.t| Table of tableElement Js.t| Tbody of tableSectionElement Js.t| Td of tableCellElement Js.t| Textarea of textAreaElement Js.t| Tfoot of tableSectionElement Js.t| Th of tableCellElement Js.t| Thead of tableSectionElement Js.t| Title of titleElement Js.t| Tr of tableRowElement Js.t| Ul of uListElement Js.t| Video of videoElement Js.t| Other of element Js.tval tagged : element Js.t -> taggedElementval opt_tagged : element Js.t Js.opt -> taggedElement optiontype taggedEvent = | MouseEvent of mouseEvent Js.t| KeyboardEvent of keyboardEvent Js.t| MessageEvent of messageEvent Js.t| MousewheelEvent of mousewheelEvent Js.t| MouseScrollEvent of mouseScrollEvent Js.t| PopStateEvent of popStateEvent Js.t| OtherEvent of event Js.tval taggedEvent : event Js.t -> taggedEventval opt_taggedEvent : event Js.t Js.opt -> taggedEvent optionmodule CoerceTo : sig ... endHTMLElement
val setTimeout : (unit -> unit) -> float -> timeout_id_safeSame as Dom_html.window##setTimeout cb ms but prevents overflow with delay greater than 24 days.
val clearTimeout : timeout_id_safe -> unitval js_array_of_collection :
element collection Js.t ->
element Js.t Js.js_array Js.tConvert a Dom_html.collection to a Js array
val _requestAnimationFrame : (unit -> unit) Js.callback -> unitCall 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.