JS 操作IE遊覽器常用函數:window.external,history,document.execCommand

來源:互聯網
上載者:User
JS 操作IE遊覽器常用函數:window.external,history,document.execCommand     

js 操作IE遊覽器 window.external...

1、window.external...
<INPUT onclick='window.external.ImportExportFavorites(true,"http://localhost");' type=button value=匯入收藏夾>
<INPUT onclick='window.external.ImportExportFavorites(false,"http://localhost");' type=button value=匯出收藏夾>
<INPUT onclick="window.external.ShowBrowserUI('OrganizeFavorites', null)" type=button value=整理收藏夾>
<INPUT onclick="window.external.ShowBrowserUI('LanguageDialog', null)" type=button value=語言設定>
<INPUT onclick="window.external.AddFavorite('http://blog.csdn.net/Opossum/', '學習,討論')" type=button value=加入收藏夾>
<INPUT onclick="window.external.addChannel('http://blog.csdn.net/Opossum/')" type=button value=加入到頻道>
      相關:<INPUT onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://blog.csdn.net/Opossum/')" type=button value=設成首頁>

2、history...
<INPUT onclick=history.go(1) type=button value=前進>
<INPUT onclick=history.go(-1) type=button value=後退>
<INPUT onclick=history.forward() type=button value=前進>
<INPUT onclick=history.back() type=button value=後退>

3、document.execCommand...
<INPUT onclick="document.execCommand('Cut')" type=button value=剪下>
<INPUT onclick="document.execCommand('Copy')" type=button value=拷貝>
<INPUT onclick="document.execCommand('Paste')" type=button value=粘貼>
<INPUT onclick="document.execCommand('Undo')" type=button value=撤消>
<INPUT onclick="document.execCommand('Delete')" type=button value=刪除>
<INPUT onclick="document.execCommand('Bold')" type=button value=黑體>
<INPUT onclick="document.execCommand('Italic')" type=button value=斜體>
<INPUT onclick="document.execCommand('Underline')" type=button value=底線>
<INPUT onclick="document.execCommand('stop')" type=button value=停止>
<INPUT onclick="document.execCommand('SaveAs')" type=button value=儲存>
<INPUT onclick="document.execCommand('Saveas',false,'c:\\test.htm')" type=button value=另存新檔>
<INPUT onclick="document.execCommand('FontName',false,fn)" type=button value=字型>
<INPUT onclick="document.execCommand('FontSize',false,fs)" type=button value=字型大小>
<INPUT onclick="document.execCommand('refresh',false,0)" type=button value=重新整理>

4、 window.location...
<INPUT onclick=window.location.reload() type=button value=重新整理 name=refresh>
<INPUT onclick='window.location="view-source:" + window.location.href' type=button value=查看源檔案 name=Button7>

5、WebBrowser.ExecWB...
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(2,1) type=button value=關閉所有><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存新檔><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=列印><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,6) type=button value=直接列印><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(7,1) type=button value=預覽列印><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=版面設定><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=屬性><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(17,1) type=button value=全選><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(22,1) type=button value=重新整理><br />
<input name=Button onClick=document.all.WebBrowser.ExecWB(45,1) type=button value=關閉>

<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id =WebBrowser width=0></OBJECT>是在頁面內載入該控制項,以便調用該控制項的方法,這個classid在系統 註冊表裡是唯一的,如果改了,就可能是別的控制項或者是不存在的控制項的id了,所以不可以更改

附WebBrowser.ExecWB裡面CMDID的參數(自己試一試):

OLECMDID_OPEN = 1,
OLECMDID_NEW = 2,
OLECMDID_SAVE = 3,
OLECMDID_SAVEAS = 4,
OLECMDID_SAVECOPYAS = 5,
OLECMDID_PRINT = 6,
OLECMDID_PRINTPREVIEW = 7,
OLECMDID_PAGESETUP = 8,
OLECMDID_SPELL = 9,
OLECMDID_PROPERTIES = 10,
OLECMDID_CUT = 11,
OLECMDID_COPY = 12,
OLECMDID_PASTE = 13,
OLECMDID_PASTESPECIAL = 14,
OLECMDID_UNDO = 15,
OLECMDID_REDO = 16,
OLECMDID_SelectALL = 17,
OLECMDID_CLEARSelectION = 18,
OLECMDID_ZOOM = 19,
OLECMDID_GETZOOMRANGE = 20,
OLECMDID_UpdateCOMMANDS = 21,
OLECMDID_REFRESH = 22,
OLECMDID_STOP = 23,
OLECMDID_HIDETOOLBARS = 24,
OLECMDID_SETPROGRESSMAX = 25,
OLECMDID_SETPROGRESSPOS = 26,
OLECMDID_SETPROGRESSTEXT = 27,
OLECMDID_SETTITLE = 28,
OLECMDID_SETDOWNLOADSTATE = 29,
OLECMDID_STOPDOWNLOAD = 30,
OLECMDID_ONTOOLBARACTIVATED = 31,
OLECMDID_FIND = 32,
OLECMDID_Delete = 33,
OLECMDID_HTTPEQUIV = 34,
OLECMDID_HTTPEQUIV_DONE = 35,
OLECMDID_ENABLE_INTERACTION = 36,
OLECMDID_ONUNLOAD = 37,
OLECMDID_PROPERTYBAG2 = 38,
OLECMDID_PREREFRESH = 39,
OLECMDID_SHOWSCRIPTERROR = 40,
OLECMDID_SHOWMESSAGE = 41,
OLECMDID_SHOWFIND = 42,
OLECMDID_SHOWPAGESETUP = 43,
OLECMDID_SHOWPRINT = 44,
OLECMDID_CLOSE = 45,
OLECMDID_ALLOWUILESSSAVEAS = 46,
OLECMDID_DONTDOWNLOADCSS = 47,
OLECMDID_UpdatePAGESTATUS = 48,
OLECMDID_PRINT2 = 49,
OLECMDID_PRINTPREVIEW2 = 50,
OLECMDID_SETPRINTTEMPLATE = 51,
OLECMDID_GETPRINTTEMPLATE = 52,
OLECMDID_PAGEACTIONBLOCKED = 55,
OLECMDID_PAGEACTIONUIQUERY = 56,
OLECMDID_FOCUSVIEWCONTROLS = 57,
OLECMDID_FOCUSVIEWCONTROLSQUERY = 58
OLECMDID_SHOWPAGEACTIONMENU = 59

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.