HTMLDOM入力URLmaxLengthプロパティ
HTMLDOM入力URLmaxLengthプロパティは、入力URLのmaxLengthプロパティを返す/設定します。定義されていない場合、このプロパティは「-1」を返します。
構文
以下は構文です-
- maxLength属性を返す
inputURLObject.maxLength
- maxLengthプロパティを数値に設定します
inputURLObject.maxLength = number
例
入力URLmaxLengthプロパティの例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<title>Input URL maxLength</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="Google">
<fieldset>
<legend>URL-maxLength</legend>
<label for="URLSelect">URL :
<input type="url" id="URLSelect" maxLength="10">
</label>
<input type="button" onclick="logIN()" value="Log In">
<input type="button" onclick="changeMaxLength()" value="Change Maxlength">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
divDisplay.textContent = 'Maxlength: '+inputURL.maxLength;
function changeMaxLength() {
inputURL.maxLength += 10;
divDisplay.textContent = 'Maxlength: '+inputURL.maxLength;
}
function logIN(){
if(inputURL.value !== '')
divDisplay.textContent = 'Could not identify url, Redirecting to '+inputURL.form.id;
}
</script>
</body>
</html> 出力
これにより、次の出力が生成されます-
[最大長の変更]をクリックする前に ボタン-
[最大長の変更]をクリックした後 ボタン-
[ログイン]をクリックした後 ボタンとメール入力の設定-
-
HTML DOMTextareamaxLengthプロパティ
HTML DOM Textarea maxLengthプロパティは、HTMLドキュメントのテキスト領域要素のmaxLength属性の値を返し、変更します。 構文 以下は構文です- 1。 maxLengthを返す object.maxLength 2。 maxLengthの変更 object.maxLength = “number” HTML DOM Textarea maxLengthプロパティの例を見てみましょう: 例 <!DOCTYPE html> <html> <style> body {
-
HTMLDOMURLプロパティ
HTML DOM URLプロパティは、ドキュメントのURLに対応する文字列を返します。 以下は構文です- 文字列値を返す document.URL HTML DOM URLの例を見てみましょう プロパティ- 例 <!DOCTYPE html> <html> <head> <title>HTML DOM URL</title> <style> form { width:70%; margin: 0 auto;