dom 實例

wKiom1drGPrjzc-kAABm6P93Pb8198.jpg

1.Anchor對象
2.Document對象
3.Event對象
4.Form,Inout對象
5.Frame對象
6.Image對象
7.Location對象
8.Navigator對象
9.Option,Select對象
10.Screen對象
11.Table對象
12.Window對象

1.Anchor對象javascript

  修改 a 屬性html

function changeA(){
    var tmp=documnent.getElementById('zcwA')
    tmp.innerHTML="切換到oxomsd"
    tmp.href="http://oxomsd.com"
    tmp.target="_blank"
}


  設定焦點、取消焦點
java

function getFocus() {
    var tmp=document.getElementById('handFocus')
    tmp.focus()
}
function loseFocus() {
    var tmp=document.getElementById('handFocus')
    tmp.blur()
}


  爲超連接添加快捷鍵(eg: Alt+F,安裝linux時經常能夠在鼠標還卡的時候快速操做
linux

function accessKey(){
    var tmpN=document.getElementById('buttonNext')
    var tmpP=document.getElementById('buttonPrevious')
    tmpN.accessKey='n'
    tmpP.accessKey='p'
}


2.Document對象ide

  添加文本內容(第三行url

<div id="w" style="height: 222px; width: 330px; background-color: #808080; padding: 50px;">
    <script type="text/javascript">                
        document.write('買保險沒有? 沒買保險上路不保險,至少要有個交強險啊!')
    </script>
</div>


  添加 html 風格的的內容spa

document.write('<h2>買保險沒有?</h2> <p>&nbsp;&nbsp;沒買保險上路不保險,至少要有個交強險啊!</p>')


  獲取文檔標題(html文件的titile標籤文本orm

document.write(document.title)

  當前文檔的urlhtm

document.write(document.URL)

  獲取文檔的 referrer(從a標籤文檔跳轉過來時,獲取a文檔路徑
對象

<a href="http://127.0.0.1:8020/Labs/writeByJavascript.html?__hbt=1508923381436" target="_blank">test</a>
<div style="border: solid">
    <p>referrer </p>
    <script type="text/javascript">
        document.write(document.referrer)
    </script>
</div>


3.Event對象

  

4.Form,Inout對象

  

5.Frame對象

  

6.Image對象

  

7.Location對象

  

8.Navigator對象

  

9.Option,Select對象

  

10.Screen對象

  

11.Table對象

  

12.Window對象

相關文章
相關標籤/搜索