Thuộc tính kích thước URL đầu vào trả về / đặt thuộc tính kích thước cho URL đầu vào. Nếu không được xác định, thuộc tính này trả về "20".
Cú pháp
Sau đây là cú pháp -
- Trả lại kích thước thuộc tính
inputURLObject.size
- Đặt thuộc tính kích thước thành một số
inputURLObject.size = number
Ví dụ
Hãy để chúng tôi xem một ví dụ về Kích thước URL đầu vào tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Input URL size</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>
<fieldset>
<legend>URL-size</legend>
<label for="URLSelect">URL:
<input type="url" id="URLSelect" size="10">
</label><br>
<input type="button" onclick="increaseVisibility()" value="Increase Visibility">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
function increaseVisibility() {
inputURL.size = 30;
divDisplay.textContent = 'Visibility Increased to '+inputURL.size;
}
</script>
</body>
</html> Đầu ra
Điều này sẽ tạo ra kết quả sau -
Trước khi nhấp vào ‘Tăng khả năng hiển thị’ nút -
Sau khi nhấp vào ‘Tăng khả năng hiển thị’ nút -