次のメソッドは非常に一般的に使用されます。脳のスペースを解放するために記録してください~
1 2 3 4 5 6 7 8 9 10 11 12 | document.title
document.bgColor
document.fgColor
document.linkColor
document.alinkColor
document.vlinkColor
document.URL
document.fileCreatedDate
document.fileModifiedDate
document. fileSize
document.cookie
document.charset
|
ログイン後にコピー
よく使用されるオブジェクト メソッド:
1 2 3 4 5 | document.write()
document.createElement(Tag)
document.getElementById(ID)
document.getElementsByName(Name)
document.body.appendChild(oTag)
|
ログイン後にコピー
body メイン サブオブジェクト:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | document.body
document.body.bgColor
document.body.link
document.body.alink
document.body.vlink
document.body.text
document.body.innerText
document.body.innerHTML
document.body.topMargin
document.body.leftMargin
document.body.rightMargin
document.body.bottomMargin
document.body.background
document.body.appendChild(oTag)
|
ログイン後にコピー
よく使用されるオブジェクト イベント:
document.body.onclick ="func()" //マウスポインターでオブジェクトをクリックするとトリガーされます
document.body.onmou<a href="http://www.php.cn/category/111.html">seo</ a>ver="func() " //マウスポインターがオブジェクトに移動するとトリガーされます
document.body.onmou<a href="http://www.php.cn/category/111.html"> seo</a>ut="func( ;
1 2 3 4 5 6 7 8 | document.location.hash
document.location.host
document.location.hostname
document.location.href
document.location.pathname
document.location.port
document.location.protocol
document.location.search
|
ログイン後にコピー
nane 属性で
1 2 3 4 | documeny.location.reload()
document.location.reload(URL)
document.location.assign(URL)
document.location.replace(URL)
|
ログイン後にコピー
を直接参照 画像
の src 属性を参照 画像
1 2 3 4 | document.images
document.images.length
document.images[0]
document.images[i]
|
ログイン後にコピー
を作成 同時に <img> ; 対応するページ上のタグを表示します
サンプルコード (動的に作成された画像):
1 2 | <img>
document.images.oImage
|
ログイン後にコピー
forms コレクション (ページ内のフォーム):
コレクションを介して参照
1 | document.images.oImage.src
|
ログイン後にコピー
タグ名属性
1 2 3 | var oImage
oImage = new Image()
document.images.oImage.src="1.jpg"
|
ログイン後にコピー
を介して直接参照
フォームのプロパティへのアクセス:
1 2 3 4 5 6 7 8 | <html>
<img>
<script>
var oImage
oImage = new Image()
document.images.oImage.src="1.jpg"
</script>
</html>
|
ログイン後にコピー
サンプル コード (フォーム):
1 2 3 4 5 6 | document.forms
document.forms.length
document.forms[0]
document.forms[i]
document.forms[i].length
document.forms[i].elements[j]
|
ログイン後にコピー
サンプル コード (チェックボックス):
1 2 | <form><input></form>
document.Myform.myctrl
|
ログイン後にコピー
サンプル コード (選択):
1 2 3 4 5 | document.forms[i].name
document.forms[i].action
document.forms[i].encoding
document.forms[i].target
document.forms[i].appendChild(oTag)
|
ログイン後にコピー
Div コレクション (ページ内のレイヤー):
1 2 3 4 5 6 7 8 9 10 11 12 | <html>
<!--Text控件相关Script-->
<form>
<input>
<input>
<form>
<script>
document.write(document.Myform.oText.value)
document.write(document.Myform.oPswd.value)
</script>
</html>
|
ログイン後にコピー
レイヤーオブジェクトの 4 つのプロパティ:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <html>
<!--checkbox,radio控件相关script-->
<form>
<input value="1">1
<input value="2">2
</form>
<script>
function fun()
{
var length
length=document.forms[0].chk.length
for (i=0;i<length;i++){
v=document.forms[0].chk[i].value
b=document.forms[0].chk[i].checked
if (b)
alert(v=v+"被选中")
else
alert(v=v+"未选中")
}
}
</script>
<a href="http:
</html>
|
ログイン後にコピー
サンプルコード:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <html>
<!--Select控件相关Script-->
<form>
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</form>
<script>
var length
length=document.Myform.oSelect.length
for (i=0;i<length;i++)
document.write(document.Myform.oSelect[i].value)
</script>
<script>
for (i=0;i<document.Myform.oSelect.length;i++)
{
if (document.Myform.oSelect[i].selected!=true)
document.write(document.Myform.oSelect[i].value)
else
document.write("<font color=red>"+document.Myform.oSelect[i].value+"</font>")
}
</script>
<script>
i=document.Myform.oSelect.selectedIndex
document.write(document.Myform.oSelect[i].value)
</script>
<script>
var oOption = document.createElement("OPTION");
oOption.text="4";
oOption.value="4";
document.Myform.oSelect.add(oOption);
</script>
<html>
|
ログイン後にコピー