위치 검색 속성은 URL에 대한 쿼리 매개변수에 해당하는 문자열을 반환/설정합니다.
구문
다음은 구문입니다 -
- 검색 의 반환 값 재산
location.search
- 프로토콜 속성 집합의 값
location.search = searchString
예시
위치 검색의 예를 살펴보겠습니다. 속성 -
<!DOCTYPE html>
<html>
<head>
<title>Location protocol</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>Location-protocol</legend>
<label for="urlSelect">Current URL:</label>
<input type="url" size="30" id="urlSelect" value="https://www.example.com:2544/aboutUs/CTO.htm">
<input type="button" onclick="getprotocol()" value="Get protocol">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var urlSelect = document.getElementById("urlSelect");
function getprotocol(){
divDisplay.textContent = 'URL protocol: '+location.protocol;
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -
'검색 가치 얻기'를 클릭하기 전에 버튼 -

'검색 가치 얻기'를 클릭한 후 버튼 -
