Javascript DOM HTML Input URL readOnly Property get

Introduction

Find out if a URL field is read-only or not:

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

Click the button to find out if the URL field is read-only.

elements with type="url" are not supported in Safari.

View in separate window

<!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.  ja  va 2s  .co  m
  var x = document.getElementById("myURL").readOnly;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related