Javascript examples for DOM HTML Element:Input URL
The readOnly property sets or gets whether a URL field should be read-only.
This property reflects the HTML readonly attribute.
Set the readOnly property with the following Values
Value | Description |
---|---|
true|false | Sets whether a URL field should be read-only |
A Boolean, returns true if the URL field is read-only, otherwise it returns false
The following code shows how to Set a URL field to read-only:
<!DOCTYPE html> <html> <body> Homepage: <input type="url" id="myURL" readonly> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w w w .j a v a 2 s. c o m document.getElementById("myURL").readOnly = true; document.getElementById("demo").innerHTML = 'set'; } </script> </body> </html>