Input URL sizeProperty

Input URL 对象参考手册Input URL Object

Example

Modify the length of the URL field:

document.getElementById("myURL").size = "50";

Try it Yourself »

Definition and Usage

The size property is used to set or return the value of the size attribute of the URL field.

The size attribute describes the length of the URL field (in characters).

The default value is 20.

Tip:If you need to set the maximum number of characters allowed in the URL field, use themaxLengthattribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the size attribute.

Note:Internet Explorer or Safari browsers do not support the HTML <input> element using the type="url" attribute.


Syntax

Return the size attribute:

urlObject.size

Set the size attribute:

urlObject.size=number

Property Values

Value Description
number Describes the length of the URL field, in characters. The default value is 20.

Technical Details

Return Value: A number, representing the length of the URL field, in characters.


More Examples

Example

Display the length of the URL field (in characters):

var x = document.getElementById("myURL").size;
xThe output result is:
30

Try it Yourself »


Related Pages

HTML Reference Manual:HTML <input> size Attribute


Input URL 对象参考手册Input URL Object Other Extensions