Input URL value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input URL

Description

The value property sets or gets the value attribute of a URL field.

Set the value property with the following Values

Value Description
URL Sets an absolute URL

Return Value

A String, representing a URL

The following code shows how to change the URL of a URL field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Homepage: <input type="url" id="myURL" value="http://www.google.com">

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//w  w w .  ja  v  a2 s. com
    document.getElementById("myURL").value = "http://java2s.com";
    document.getElementById("demo").innerHTML = 'changed';
}
</script>

</body>
</html>

Related Tutorials