The readOnly
property sets or gets whether or not a URL field should be read-only.
readOnly |
Yes | 10.0 | Yes | Yes | Yes |
Return the readOnly property.
var v = urlObject.readOnly
Set the readOnly property.
urlObject.readOnly=true|false
Value | Description |
---|---|
true|false | Set whether or not a URL field should be read-only
|
A Boolean type value, true if the URL field is read-only, otherwise false.
The following code shows how to check if a URL field is read-only or not.
<!DOCTYPE html>
<html>
<body>
<!--from w w w. j av a 2 s. c om-->
Homepage: <input type="url" id="myURL" readonly>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myURL").readOnly;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to set a URL field to read-only.
<!DOCTYPE html>
<html>
<body>
<!-- w w w . j a v a 2 s. c om-->
Homepage: <input type="url" id="myURL">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myURL").readOnly = true;
}
</script>
</body>
</html>
The code above is rendered as follows: