Js_of_ocaml.Dom_html
DOM HTML binding
This is a partial binding to the DOM HTML API.
class type cssStyleDeclaration = object ... end
type (-'a, -'b) event_listener = ('a, 'b) 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.
class type event = object ... end
class type 'a customEvent = object ... end
class type focusEvent = 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 submitEvent = object ... end
class type dragEvent = object ... end
class type clipboardEvent = 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 pointerEvent = 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
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 divElement = element
class type paragraphElement = element
class type headingElement = element
class type quoteElement = object ... end
class type preElement = 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 tableCaptionElement = element
class type tableElement = object ... end
class type timeRanges = object ... end
class type mediaElement = object ... end
class type audioElement = object ... end
class type videoElement = object ... end
val _2d_ : context
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.t -> int -> int
val pixel_set : canvasPixelArray Js.t -> int -> int -> unit
class type range = object ... end
Object representing a range *
class type selection = object ... end
Information on current selection
class type document = object ... end
getElementById_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 ... end
Location information
val location_origin : location Js.t -> Js.js_string Js.t
class type history = object ... end
Browser history information
class type undoManager = object ... end
Undo manager
Navigator information
class type screen = object ... end
class type applicationCache = object ... end
class type _URL = object ... end
class type window = object ... end
Specification of window objects
class type frameSetElement = object ... end
class type frameElement = object ... end
class type iFrameElement = object ... end
val no_handler : ('a, 'b) event_listener
see Dom.no_handler
val handler : (event Js.t as 'b -> bool Js.t) -> ('a, 'b) event_listener
see Dom.handler
val full_handler : ('a -> event Js.t as 'b -> bool Js.t) -> ('a, 'b) event_listener
see Dom.full_handler
val invoke_handler : ('a, 'b) event_listener -> 'a -> 'b -> bool Js.t
see Dom.invoke_handler
module Event : sig ... end
Event types: mousedown
, keypress
, ...
type event_listener_id = Dom.event_listener_id
val 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_id
Add 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_id
Add 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 -> unit
Remove the given event listener.
val addMousewheelEventListenerWithOptions : eventTarget Js.t as 'a -> ?capture:bool Js.t ->
?once:bool Js.t -> ?passive:bool Js.t -> (mouseEvent Js.t -> dx:int -> dy:int -> bool Js.t) -> event_listener_id
Add a mousewheel 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 as 'a -> (mouseEvent Js.t -> dx:int -> dy:int -> bool Js.t) -> bool Js.t -> event_listener_id
Add a mousewheel 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.t
See Dom.createCustomEvent
val buttonPressed : mouseEvent Js.t -> mouse_button
val eventAbsolutePosition : mouseEvent Js.t -> int * int
Returns the absolute position of the mouse pointer.
val elementClientPosition : element Js.t -> int * int
Position of an element relative to the viewport
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.
val createHtml : document Js.t -> htmlElement Js.t
val createHead : document Js.t -> headElement Js.t
val createLink : document Js.t -> linkElement Js.t
val createTitle : document Js.t -> titleElement Js.t
val createMeta : document Js.t -> metaElement Js.t
val createBase : document Js.t -> baseElement Js.t
val createStyle : document Js.t -> styleElement Js.t
val createBody : document Js.t -> bodyElement Js.t
val createForm : document Js.t -> formElement Js.t
val createOptgroup : document Js.t -> optGroupElement Js.t
val createOption : document Js.t -> optionElement Js.t
val createSelect : ?_type:Js.js_string Js.t -> ?name:Js.js_string Js.t -> document Js.t -> selectElement Js.t
val createInput : ?_type:Js.js_string Js.t -> ?name:Js.js_string Js.t -> document Js.t -> inputElement Js.t
val createTextarea : ?_type:Js.js_string Js.t -> ?name:Js.js_string Js.t -> document Js.t -> textAreaElement Js.t
val createButton : ?_type:Js.js_string Js.t -> ?name:Js.js_string Js.t -> document Js.t -> buttonElement Js.t
val createLabel : document Js.t -> labelElement Js.t
val createFieldset : document Js.t -> fieldSetElement Js.t
val createLegend : document Js.t -> legendElement Js.t
val createUl : document Js.t -> uListElement Js.t
val createOl : document Js.t -> oListElement Js.t
val createDl : document Js.t -> dListElement Js.t
val createDiv : document Js.t -> divElement Js.t
val createEmbed : document Js.t -> embedElement Js.t
val createP : document Js.t -> paragraphElement Js.t
val createH1 : document Js.t -> headingElement Js.t
val createH2 : document Js.t -> headingElement Js.t
val createH3 : document Js.t -> headingElement Js.t
val createH4 : document Js.t -> headingElement Js.t
val createH5 : document Js.t -> headingElement Js.t
val createH6 : document Js.t -> headingElement Js.t
val createQ : document Js.t -> quoteElement Js.t
val createBlockquote : document Js.t -> quoteElement Js.t
val createPre : document Js.t -> preElement Js.t
val createIns : document Js.t -> modElement Js.t
val createDel : document Js.t -> modElement Js.t
val createA : document Js.t -> anchorElement Js.t
val createImg : document Js.t -> imageElement Js.t
val createObject : document Js.t -> objectElement Js.t
val createParam : document Js.t -> paramElement Js.t
val createMap : document Js.t -> mapElement Js.t
val createArea : document Js.t -> areaElement Js.t
val createScript : document Js.t -> scriptElement Js.t
val createTable : document Js.t -> tableElement Js.t
val createCaption : document Js.t -> tableCaptionElement Js.t
val createCol : document Js.t -> tableColElement Js.t
val createColgroup : document Js.t -> tableColElement Js.t
val createThead : document Js.t -> tableSectionElement Js.t
val createTfoot : document Js.t -> tableSectionElement Js.t
val createTbody : document Js.t -> tableSectionElement Js.t
val createTr : document Js.t -> tableRowElement Js.t
val createTh : document Js.t -> tableCellElement Js.t
val createTd : document Js.t -> tableCellElement Js.t
val createFrameset : document Js.t -> frameSetElement Js.t
val createFrame : document Js.t -> frameElement Js.t
val createIframe : document Js.t -> iFrameElement Js.t
val createAudio : document Js.t -> audioElement Js.t
val createVideo : document Js.t -> videoElement Js.t
val createCanvas : document Js.t -> canvasElement Js.t
Coercion from a general DOM element to an HTML element. (Unsafe in general.)
type taggedElement =
val tagged : element Js.t -> taggedElement
val opt_tagged : element Js.t Js.opt -> taggedElement option
type taggedEvent =
| MouseEvent of mouseEvent Js.t |
| KeyboardEvent of keyboardEvent Js.t |
| MousewheelEvent of mousewheelEvent Js.t |
| MouseScrollEvent of mouseScrollEvent Js.t |
| PopStateEvent of popStateEvent Js.t |
| OtherEvent of event Js.t |
val taggedEvent : event Js.t -> taggedEvent
val opt_taggedEvent : event Js.t Js.opt -> taggedEvent option
val stopPropagation : event Js.t -> unit
module CoerceTo : sig ... end
HTMLElement
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
val js_array_of_collection : element collection Js.t -> element Js.t Js.js_array Js.t
Convert a Dom_html.collection
to a Js array
val _requestAnimationFrame : (unit -> unit) 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.