Get Input URL Field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input URL

Introduction

The Input URL object represents an HTML <input> element with type="url".

You can access an <input> element with type="url" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="url" id="myURL" value="http://www.java2s.com">

<button onclick="myFunction()">get the URL of the URL field</button>

<p id="demo"></p>

<script>
function myFunction() {//from   w ww  .  ja  v a2  s .c o m
    var x = document.getElementById("myURL").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials