HTMLDOMロケーション検索プロパティ
場所検索プロパティは、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> 出力
これにより、次の出力が生成されます-
[検索値を取得]をクリックする前に ボタン-
[検索値を取得]をクリックした後 ボタン-
-
HTMLDOM入力検索値プロパティ
HTML DOM入力検索値プロパティは、type =” search”を持つ入力要素とvalue属性に関連付けられています。入力検索フィールド値属性の値を返すか、設定するために使用されます。このプロパティは、検索フィールドのデフォルト値を指定するために使用され、値をユーザー入力に変更します。 構文 以下は、-の構文です。 値プロパティの設定- searchObject.value = text; ここでは、検索フィールドの値を指定するためにテキストが使用されています。 例 入力検索値プロパティの例を見てみましょう- <!DOCTYPE html> <html>
-
HTMLDOM入力検索タイププロパティ
HTML DOM入力検索タイププロパティは、type =” search”を持つ入力要素に関連付けられています。入力検索要素の検索を常に返します。 構文 以下は、検索タイププロパティの構文です- searchObject.type 例 入力検索タイププロパティの例を見てみましょう- <!DOCTYPE html> <html> <body> <h1>Search type property</h1> <form> FRUITS: <input type="search" id="SE