Input URL readOnly Attribute

Definition and Usage

readOnly Set or return whether the URL field should be read-only.

Read-only fields cannot be modified. However, users can select, highlight it, and copy text from it.

This property reflects the HTML readonly attribute.

Tip:To prevent users from interacting with the field, use disabled Properties.

See also:

HTML Reference Manual:HTML <input> readonly Attribute

Example

Example 1

Set the URL field to read-only:

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

Try it yourself

Example 2

Determine if the URL field is read-only:

var x = document.getElementById("myURL").readOnly;

Try it yourself

Syntax

Return the readOnly property:

urlObject.readOnly

Set the readOnly property:

urlObject.readOnly = true|false

Attribute value

Value Description
true|false

The URL field should be read-only.

  • true - The URL field is read-only
  • false - Default. The URL field is not read-only

Technical Details

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

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 10.0 Supported Not Supported Supported