HTML DOM 입력 URL readOnly 속성은 입력 URL을 수정할 수 있는지 여부를 설정/반환합니다.
구문
다음은 구문입니다 -
- 부울 값 반환 - true/false
inputURLObject.readOnly
- 읽기 전용 설정 booleanValue로
inputURLObject.readOnly = booleanValue
부울 값
여기 "booleanValue" 다음과 같을 수 있습니다 -
| 부울 값 | 세부정보 |
|---|---|
| 참 | 입력 url 필드가 readOnly임을 정의합니다. |
| 거짓 | 입력 url 필드가 readOnly가 아니며 수정할 수 있음을 정의합니다. |
예시
입력 URL 읽기 전용의 예를 살펴보겠습니다. 속성 -
<!DOCTYPE html>
<html>
<head>
<title>Input URL readOnly</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-readOnly</legend>
<label for="URLSelect">Contact Us :
<input type="url" id="URLSelect" onclick="showErrorMsg()" value="https://www.google.com" readOnly>
</label>
<input type="button" onclick="showMessage()" value="Copy URL">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
divDisplay.textContent = 'Above URL is read-only';
function showMessage() {
inputURL.select();
document.execCommand('copy');
divDisplay.textContent = 'URL Copied: '+inputURL.value;
}
function showErrorMsg(){
divDisplay.textContent +=', This cannot be edited.'
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -
'URL 복사'를 클릭하기 전에 버튼 -

'문의하기' 클릭 URL 필드 -

'URL 복사' 클릭 버튼 -
