The value
property sets or gets the value attribute of a URL field.
value |
Yes | 10.0 | Yes | Yes | Yes |
Return the value property.
var v = urlObject.value
Set the value property.
urlObject.value=URL
Value | Description |
---|---|
URL | Get an absolute URL |
A String type value representing a URL.
The following code shows how to change the URL of a URL field.
<!DOCTYPE html>
<html>
<body>
Homepage: <input type="url" id="myURL" value="http://www.google.com">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!-- w w w .j av a 2 s.co m-->
<script>
function myFunction() {
document.getElementById("myURL").value = "http://www.cnn.com";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get the URL of a URL field.
<!DOCTYPE html>
<html>
<body>
Homepage: <input type="url" id="myURL" value="http://www.google.com">
<button onclick="myFunction()">test</button>
<!--from w w w. j a v a 2 s. c o m-->
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myURL").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: