Thuộc tính biểu mẫu URL đầu vào HTML DOM trả về tham chiếu của biểu mẫu kèm theo cho URL đầu vào.
Cú pháp
Sau đây là cú pháp -
Trả lại tham chiếu cho đối tượng biểu mẫu
inputURLObject.form
Ví dụ
Hãy để chúng tôi xem ví dụ về Biểu mẫu URL đầu vào tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Input URL form</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form id="Larry Page">
<fieldset>
<legend>URL-form</legend>
<label for="URLSelect">URL :
<input type="URL" id="URLSelect" size="25">
</label>
<input type="button" onclick="getform()" value="Get Co-founder">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
function getform() {
if(inputURL.value !== '')
divDisplay.textContent = 'Co-founder: '+inputURL.form.id;
else
divDisplay.textContent = 'Please enter valid URL';
}
</script>
</body>
</html> Đầu ra
Điều này sẽ tạo ra kết quả sau -
Trước khi nhấp vào ‘Nhận người đồng sáng lập’ nút -
Sau khi chọn ‘Nhận người đồng sáng lập’ nút -