天天看點

ios與js互動,擷取webview完整url,title,擷取元素并指派跳轉 document、location、body 屬性方法 JS 對象

轉載自:  http://blog.sina.com.cn/s/blog_6ae8b50d01011rri.html

檢視原文:http://www.heyuan110.com

 使用webview的stringByEvaluatingJavaScriptFromString的方法互動,直接提供執行個體。

下載下傳:http://download.csdn.net/detail/heyuan110/4420050

附上document、location、body 屬性方法 JS 對象

document:屬性

document.title                 //設定文檔标題等價于HTML的<title>标簽

document.bgColor               //設定頁面背景色

document.fgColor               //設定前景色(文本顔色)

document.linkColor             //未點選過的連結顔色

document.alinkColor            //激活連結(焦點在此連結上)的顔色

document.vlinkColor            //已點選過的連結顔色

document.URL                   //設定URL屬性進而在同一視窗打開另一網頁

document.fileCreatedDate       //檔案建立日期,隻讀屬性

document.fileModifiedDate      //檔案修改日期,隻讀屬性

document.fileSize              //檔案大小,隻讀屬性

document.cookie                //設定和讀出cookie

document.charset               //設定字元集 簡體中文:gb2312

document:方法

document.write()                      //動态向頁面寫入内容

document_createElement_x_x(Tag)           //建立一個html标簽對象

document.getElementByIdx_x_x(ID)           //獲得指定ID值的對象

document.getElementsByName(Name)      //獲得指定Name值的對象

document.body.a(oTag)

body:子對象

document.body                   //指定文檔主體的開始和結束等價于<body></body>

document.body.bgColor           //設定或擷取對象後面的背景顔色

document.body.link              //未點選過的連結顔色

document.body.alink             //激活連結(焦點在此連結上)的顔色

document.body.vlink             //已點選過的連結顔色

document.body.text              //文本色

document.body.innerText         //設定<body>...</body>之間的文本

document.body.innerHTML         //設定<body>...</body>之間的HTML代碼

document.body.topMargin         //頁面上邊距

document.body.leftMargin        //頁面左邊距

document.body.rightMargin       //頁面右邊距

document.body.bottomMargin      //頁面下邊距

document.body.background        //背景圖檔

document.body.a(oTag) //動态生成一個HTML對象

location:子對象

document.location.hash          // #号後的部分

document.location.host          // 域名+端口号

document.location.hostname      // 域名

document.location.href          // 完整URL

document.location.pathname      // 目錄部分

document.location.port          // 端口号

document.location.protocol      // 網絡協定(http:)

document.location.search        // ?号後的部分

常用對象事件:

documeny.location.reload()          //重新整理網頁

document.location.reload(URL)       //打開新的網頁

document.location.assign(URL)       //打開新的網頁

document.location.replace(URL)      //打開新的網頁

selection-選區子對象

document.selection

document、location、body 屬性方法 JS 對象