JS 加入收藏夾的代碼(主流瀏覽器通用)
更新時間:2013年05月13日 15:26:40 作者:
所有瀏覽器通用的js添加收藏夾代碼,本文整理了多種方法實現(xiàn)加入收藏夾功能,下面為大家詳細介紹下實現(xiàn)代碼,感興趣的朋友可以參考下哈
所有瀏覽器通用的js添加收藏夾代碼
<script>
function addfavorite()
{
if (document.all)
{
window.external.addFavorite('http://www.XXX.com','XXX');
}
else if (window.sidebar)
{
window.sidebar.addPanel('XXX', 'http://www.XXX.com', "");
}
}
</script>
<a href="#" onclick="addfavorite()">XXX</a>
打開,另存為,屬性,打印"等14個JS代碼
■刷新■
■導入收藏■
■導出收藏■
■整理收藏夾■
■查看原文件■
■語言設(shè)置■
■打開■
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打開>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■另存為■
<input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存為><OBJECT classid=CLSID:8856F961-
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■屬性■
<input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=屬性><OBJECT classid=CLSID:8856F961-
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■打印■
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印><OBJECT classid=CLSID:8856F961-
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■頁面設(shè)置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設(shè)置><OBJECT classid=CLSID:8856F961
-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■刷新■
<input type=button value=刷新 name=refresh onclick="window.location.reload()">
■導入收藏■
<input type="button" name="Button" value="導入收藏夾" onClick=window.external.ImportExportFavorites(true,);>
■導出收藏■
<input type="button" name="Button3" value="導出收藏夾" onClick=window.external.ImportExportFavorites(false,);>
■加入收藏■
<INPUT name=Button2 onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夾>
■整理收藏夾■
<INPUT name=Submit2 onclick="window.external.ShowBrowserUI(OrganizeFavorites, null)" type=button value=整理收藏夾>
■查看原文件■
<INPUT name=Button onclick=window.location = "view-source:" + window.location.href type=button value=查看源文件>
■語言設(shè)置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語言設(shè)置>
■前進■
<INPUT name=Submit onclick=history.go(1) type=submit value=前進>
■后退■
<INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退>
- 作者: gatebill 2005年11月1日, 星期二 12:42 回復(fù)(0) | 引用(0) 加入博采
JS實現(xiàn)瀏覽器菜單命令
每當我們看到別人網(wǎng)頁上的打開、打印、前進、另存為、后退、關(guān)閉本窗口、禁用右鍵等實現(xiàn)瀏覽器命令的鏈接,而自己苦于不能實現(xiàn)時
,是不是感到很遺憾?是不是也想實現(xiàn)?如果能在網(wǎng)頁上能實現(xiàn)瀏覽器的命令,將是多么有意思的事啊!下面我們就來看看如何用
Javascript代碼實現(xiàn)瀏覽器菜單命令(以下代碼在Windows XP下的瀏覽器中調(diào)試通過)。
一、【文件(F)】菜單中的命令的實現(xiàn)
1、〖打開〗命令的實現(xiàn)
[格式]:document.execCommand("open")
[說明]這跟VB等編程設(shè)計中的webbrowser控件中的命令有些相似,大家也可依此琢磨琢磨。
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("open")>打開</a>
2、〖使用 記事本 編輯〗命令的實現(xiàn)
[格式]:location.replace("view-source:"+location)
[說明]打開記事本,在記事本中顯示該網(wǎng)頁的源代碼。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.replace("view-source:"+location)>使用 記事本 編輯</a>
3、〖另存為〗命令的實現(xiàn)
[格式]:document.execCommand("saveAs")
[說明]將該網(wǎng)頁保存到本地盤的其它目錄!
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("saveAs")>另存為</a>
4、〖打印〗命令的實現(xiàn)
[格式]:document.execCommand("print")
[說明]當然,你必須裝了打印機!
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("print")>打印</a>
5、〖關(guān)閉〗命令的實現(xiàn)
[格式]:window.close();return false
[說明]將關(guān)閉本窗口。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.close();return false)>關(guān)閉本窗口</a>
二、【編輯(E)】菜單中的命令的實現(xiàn)
〖全選〗命令的實現(xiàn)
[格式]:document.execCommand("selectAll")
[說明]將選種網(wǎng)頁中的全部內(nèi)容!
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("selectAll")>全選</a>
三、【查看(V)】菜單中的命令的實現(xiàn)
1、〖刷新〗命令的實現(xiàn)
[格式]:location.reload() 或 history.go(0)
[說明]瀏覽器重新打開本頁。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.reload()>刷新</a>
或加入:<a href="#" onclick=history.go(0)>刷新</a>
2、〖源文件〗命令的實現(xiàn)
[格式]:location.replace("view-source:"+location)
[說明]查看該網(wǎng)頁的源代碼。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.replace("view-source:"+location)>查看源文件</a>
3、〖全屏顯示〗命令的實現(xiàn)
[格式]:window.open(document.location,"url","fullscreen")
[說明]全屏顯示本頁。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.open(document.location,"url","fullscreen")>全屏顯示</a>
四、【收藏(A)】菜單中的命令的實現(xiàn)
1、〖添加到收藏夾〗命令的實現(xiàn)
[格式]:window.external.AddFavorite('url', '"網(wǎng)站名")
[說明]將本頁添加到收藏夾。
[舉例]在<body></body>之間加入:
<a href="javascript:window.external.AddFavorite('添加到收藏夾 " target="_blank">http://oh.jilinfarm.com', '胡明新的個
人主頁')">添加到收藏夾</a>
2、〖整理收藏夾〗命令的實現(xiàn)
[格式]:window.external.showBrowserUI("OrganizeFavorites",null)
[說明]打開整理收藏夾對話框。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夾</a>
五、【工具(T)】菜單中的命令的實現(xiàn)
〖internet選項〗命令的實現(xiàn)
[格式]:window.external.showBrowserUI("PrivacySettings",null)
[說明]打開internet選項對話框。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.external.showBrowserUI("PrivacySettings",null)>internet選項</a>
六、【工具欄】中的命令的實現(xiàn)
1、〖前進〗命令的實現(xiàn)
[格式]history.go(1) 或 history.forward()
[說明]瀏覽器打開后一個頁面。
[舉例]在<body></body>之間加入:
<a href="#" onclick=history.go(1)>前進</a>
或加入:<a href="#" onclick=history.forward()>前進</a>
2、〖后退〗命令的實現(xiàn)
[格式]:history.go(-1) 或 history.back()
[說明]瀏覽器返回上一個已瀏覽的頁面。
[舉例]在<body></body>之間加入:
<a href="#" onclick=history.go(-1)>后退</a>
或加入:<a href="#" onclick=history.back()>后退</a>
3、〖刷新〗命令的實現(xiàn)
[格式]:document.reload() 或 history.go(0)
[說明]瀏覽器重新打開本頁。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.reload()>刷新</a>
或加入:<a href="#" onclick=history.go(0)>刷新</a>
七、其它命令的實現(xiàn)
〖定時關(guān)閉本窗口〗命令的實現(xiàn)
[格式]:settimeout(window.close(),關(guān)閉的時間)
[說明]將關(guān)閉本窗口。
[舉例]在<body></body>之間加入:
<a href="#" onclick=setTimeout(window.close(),3000)>3秒關(guān)閉本窗口</a>
復(fù)制代碼 代碼如下:
<script>
function addfavorite()
{
if (document.all)
{
window.external.addFavorite('http://www.XXX.com','XXX');
}
else if (window.sidebar)
{
window.sidebar.addPanel('XXX', 'http://www.XXX.com', "");
}
}
</script>
<a href="#" onclick="addfavorite()">XXX</a>
打開,另存為,屬性,打印"等14個JS代碼
■刷新■
■導入收藏■
■導出收藏■
■整理收藏夾■
■查看原文件■
■語言設(shè)置■
■打開■
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打開>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■另存為■
<input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存為><OBJECT classid=CLSID:8856F961-
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■屬性■
<input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=屬性><OBJECT classid=CLSID:8856F961-
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■打印■
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印><OBJECT classid=CLSID:8856F961-
340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■頁面設(shè)置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=頁面設(shè)置><OBJECT classid=CLSID:8856F961
-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■刷新■
<input type=button value=刷新 name=refresh onclick="window.location.reload()">
■導入收藏■
<input type="button" name="Button" value="導入收藏夾" onClick=window.external.ImportExportFavorites(true,);>
■導出收藏■
<input type="button" name="Button3" value="導出收藏夾" onClick=window.external.ImportExportFavorites(false,);>
■加入收藏■
<INPUT name=Button2 onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夾>
■整理收藏夾■
<INPUT name=Submit2 onclick="window.external.ShowBrowserUI(OrganizeFavorites, null)" type=button value=整理收藏夾>
■查看原文件■
<INPUT name=Button onclick=window.location = "view-source:" + window.location.href type=button value=查看源文件>
■語言設(shè)置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=語言設(shè)置>
■前進■
<INPUT name=Submit onclick=history.go(1) type=submit value=前進>
■后退■
<INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退>
- 作者: gatebill 2005年11月1日, 星期二 12:42 回復(fù)(0) | 引用(0) 加入博采
JS實現(xiàn)瀏覽器菜單命令
每當我們看到別人網(wǎng)頁上的打開、打印、前進、另存為、后退、關(guān)閉本窗口、禁用右鍵等實現(xiàn)瀏覽器命令的鏈接,而自己苦于不能實現(xiàn)時
,是不是感到很遺憾?是不是也想實現(xiàn)?如果能在網(wǎng)頁上能實現(xiàn)瀏覽器的命令,將是多么有意思的事啊!下面我們就來看看如何用
Javascript代碼實現(xiàn)瀏覽器菜單命令(以下代碼在Windows XP下的瀏覽器中調(diào)試通過)。
一、【文件(F)】菜單中的命令的實現(xiàn)
1、〖打開〗命令的實現(xiàn)
[格式]:document.execCommand("open")
[說明]這跟VB等編程設(shè)計中的webbrowser控件中的命令有些相似,大家也可依此琢磨琢磨。
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("open")>打開</a>
2、〖使用 記事本 編輯〗命令的實現(xiàn)
[格式]:location.replace("view-source:"+location)
[說明]打開記事本,在記事本中顯示該網(wǎng)頁的源代碼。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.replace("view-source:"+location)>使用 記事本 編輯</a>
3、〖另存為〗命令的實現(xiàn)
[格式]:document.execCommand("saveAs")
[說明]將該網(wǎng)頁保存到本地盤的其它目錄!
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("saveAs")>另存為</a>
4、〖打印〗命令的實現(xiàn)
[格式]:document.execCommand("print")
[說明]當然,你必須裝了打印機!
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("print")>打印</a>
5、〖關(guān)閉〗命令的實現(xiàn)
[格式]:window.close();return false
[說明]將關(guān)閉本窗口。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.close();return false)>關(guān)閉本窗口</a>
二、【編輯(E)】菜單中的命令的實現(xiàn)
〖全選〗命令的實現(xiàn)
[格式]:document.execCommand("selectAll")
[說明]將選種網(wǎng)頁中的全部內(nèi)容!
[舉例]在<body></body>之間加入:
<a href="#" onclick=document.execCommand("selectAll")>全選</a>
三、【查看(V)】菜單中的命令的實現(xiàn)
1、〖刷新〗命令的實現(xiàn)
[格式]:location.reload() 或 history.go(0)
[說明]瀏覽器重新打開本頁。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.reload()>刷新</a>
或加入:<a href="#" onclick=history.go(0)>刷新</a>
2、〖源文件〗命令的實現(xiàn)
[格式]:location.replace("view-source:"+location)
[說明]查看該網(wǎng)頁的源代碼。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.replace("view-source:"+location)>查看源文件</a>
3、〖全屏顯示〗命令的實現(xiàn)
[格式]:window.open(document.location,"url","fullscreen")
[說明]全屏顯示本頁。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.open(document.location,"url","fullscreen")>全屏顯示</a>
四、【收藏(A)】菜單中的命令的實現(xiàn)
1、〖添加到收藏夾〗命令的實現(xiàn)
[格式]:window.external.AddFavorite('url', '"網(wǎng)站名")
[說明]將本頁添加到收藏夾。
[舉例]在<body></body>之間加入:
<a href="javascript:window.external.AddFavorite('添加到收藏夾 " target="_blank">http://oh.jilinfarm.com', '胡明新的個
人主頁')">添加到收藏夾</a>
2、〖整理收藏夾〗命令的實現(xiàn)
[格式]:window.external.showBrowserUI("OrganizeFavorites",null)
[說明]打開整理收藏夾對話框。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夾</a>
五、【工具(T)】菜單中的命令的實現(xiàn)
〖internet選項〗命令的實現(xiàn)
[格式]:window.external.showBrowserUI("PrivacySettings",null)
[說明]打開internet選項對話框。
[舉例]在<body></body>之間加入:
<a href="#" onclick=window.external.showBrowserUI("PrivacySettings",null)>internet選項</a>
六、【工具欄】中的命令的實現(xiàn)
1、〖前進〗命令的實現(xiàn)
[格式]history.go(1) 或 history.forward()
[說明]瀏覽器打開后一個頁面。
[舉例]在<body></body>之間加入:
<a href="#" onclick=history.go(1)>前進</a>
或加入:<a href="#" onclick=history.forward()>前進</a>
2、〖后退〗命令的實現(xiàn)
[格式]:history.go(-1) 或 history.back()
[說明]瀏覽器返回上一個已瀏覽的頁面。
[舉例]在<body></body>之間加入:
<a href="#" onclick=history.go(-1)>后退</a>
或加入:<a href="#" onclick=history.back()>后退</a>
3、〖刷新〗命令的實現(xiàn)
[格式]:document.reload() 或 history.go(0)
[說明]瀏覽器重新打開本頁。
[舉例]在<body></body>之間加入:
<a href="#" onclick=location.reload()>刷新</a>
或加入:<a href="#" onclick=history.go(0)>刷新</a>
七、其它命令的實現(xiàn)
〖定時關(guān)閉本窗口〗命令的實現(xiàn)
[格式]:settimeout(window.close(),關(guān)閉的時間)
[說明]將關(guān)閉本窗口。
[舉例]在<body></body>之間加入:
<a href="#" onclick=setTimeout(window.close(),3000)>3秒關(guān)閉本窗口</a>
相關(guān)文章
js實現(xiàn)樹形數(shù)據(jù)轉(zhuǎn)成扁平數(shù)據(jù)的方法示例
這篇文章主要介紹了js實現(xiàn)樹形數(shù)據(jù)轉(zhuǎn)成扁平數(shù)據(jù)的方法示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-02-02JavaScript數(shù)據(jù)操作_淺談原始值和引用值的操作本質(zhì)
下面小編就為大家?guī)硪黄狫avaScript數(shù)據(jù)操作_淺談原始值和引用值的操作本質(zhì)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-08document.getElementById為空或不是對象的解決方法
document.getElementById為空或不是對象的解決方法,一般情況下注意先內(nèi)容后js.2010-01-01微信小程序?qū)崿F(xiàn)錄制、試聽、上傳音頻功能(帶波形圖)
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)錄制、試聽、上傳音頻功能(帶波形圖),本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2020-02-02