Input URL readOnlyProperty

Input URL 对象参考手册Input URL Object

Example

Set the URL field to read-only:

document.getElementById("myURL").readOnly = true;

Output:


Try it Yourself »

Definition and Usage

The readOnly property is used to set or return whether the URL field is read-only.

A read-only field cannot be modified. However, the content of the field can be copied.

This property reflects the HTML readonly attribute.

Tip:To ensure the accuracy of form data, you can use thedisabledproperty instead.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the readOnly property.

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


Syntax

Return the readOnly property:

urlObject.readOnly

Set the readOnly property:

urlObject.readOnly=true|false

Property Values

Value Description
true|false Describes whether the URL field is read-only
  • true - The URL field is read-only
  • false - Default. The URL field is not read-only

Technical Details

Return Value: A Boolean value, returns true if the URL field is read-only, otherwise returns false.


More Examples

Example

Check whether the URL field is read-only:

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

Try it Yourself »


Related Pages

HTML Reference Manual:HTML <input> readonly Attribute


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