天天看點

Input URL maxLength 屬性

Input URL maxLength 屬性

Input URL 對象

擷取 URL 字段允許輸入的最大字元數:

var x = document.getElementById("myURL").maxLength;

x輸出結果為:

30

maxLength 屬性用于設定或者傳回 URL 字段的 maxlength 屬性。

maxLength 屬性描述了 URL 字段允許輸入的最大字元數。

預設值為 524288。

提示: 如果需要設定 URL 的長度,即字元數,請使用 size 屬性。

Input URL maxLength 屬性
Input URL maxLength 屬性
Input URL maxLength 屬性
Input URL maxLength 屬性
Input URL maxLength 屬性

所有主流浏覽器都支援 maxLength 屬性

注意: Internet Explorer 或 Safari 浏覽器不支援使用 type="url" 屬性的 HTML <input> 元素。

傳回 maxLength 屬性:

urlObject.maxLength

設定 maxLength 屬性:

urlObject.maxLength=number

描述

number

描述了 URL 字段允許輸入的最大字元數。

預設值為 524288

傳回值:

數字,表示 URL 字段允許輸入的最大字元數。

設定 URL 字段允許輸入的最大字元數:

document.getElementById("myURL").maxLength = "8";

HTML 參考手冊: HTML <input> maxlength 屬性

Input URL maxLength 屬性