Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input URL Object

HTML DOM Input URL Object


The Input URL object

The Input URL object is new in HTML5.

The Input URL object represents an HTML element that uses the type="url" attribute .

**Note:** Internet Explorer 9 (and earlier versions), or the Safari browser, does not support the HTML element that uses the type="url" attribute .

Access the Input URL Object

You can use the getElementById() function to access the element that uses the type="url" attribute element:

var x = document.getElementById("myUrl");

Try it

Tip: You can also access the Input Color object through a form'sElementcollection to access the Input URL object.

Create the Input URL Object

You can use the document.createElement() method to create the element that uses the type="url" attribute element:

var x = document.createElement("INPUT");

x.setAttribute("type", "url");

Try it

Input URL Object Properties

property Description
autocomplete Sets or returns the value of the autocomplete attribute of the URL field
autofocus Sets or returns whether the URL field automatically gets focus after the page loads
defaultValue Sets or returns the default value of the URL field
disabled Sets or returns whether the URL field is enabled
form Returns a reference to the form that uses the URL field
list Returns a reference to the datalist that contains the URL field
maxLength Sets or returns the value of the maxlength attribute of the URL field
multiple Sets or returns whether the URL field allows the user to enter one or more url addresses.
name Sets or returns the value of the name attribute of the URL field
pattern Sets or returns the value of the pattern attribute of the URL field
placeholder Sets or returns the value of the placeholder attribute of the URL field
readOnly Sets or returns whether the URL field is read-only
required Sets or returns whether the URL field is required in the form
size Sets or returns the value of the size attribute of the URL field
step Sets or returns the value of the step attribute of the URL field
type Returns the form element type of the URL field
value Sets or returns the value of the value attribute of the URL field

Standard properties and events

The Input URL object also supports standard property and Events.


Related Articles

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML tag

HTML Reference Manual: HTML type Attribute