![](http://static.javashuo.com/static/loading.gif)
<script type="text/JavaScript">//設爲首頁function SetHome(obj,url){ try{ obj.style.behavior='url(#default#homepage)'; obj.setHomePage(url); }catch(e){ if(window.netscape){ try{ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }catch(e){ alert("抱歉,此操做被瀏覽器拒絕!\n\n請在瀏覽器地址欄輸入「about:config」並回車而後將[signed.applets.codebase_principal_support]設置爲'true'"); } }else{ alert("抱歉,您所使用的瀏覽器沒法完成此操做。\n\n您須要手動將【"+url+"】設置爲首頁。"); } }}//收藏本站function AddFavorite(title, url) { try { window.external.addFavorite(url, title); } catch (e) { try { window.sidebar.addPanel(title, url, ""); } catch (e) { alert("抱歉,您所使用的瀏覽器沒法完成此操做。\n\n加入收藏失敗,請使用Ctrl+D進行添加"); } }}//保存到桌面function toDesktop(sUrl,sName){try { var WshShell = new ActiveXObject("WScript.Shell"); var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "\\" + sName + ".url"); oUrlLink.TargetPath = sUrl; oUrlLink.Save(); } catch(e) { alert("當前IE安全級別不容許操做!"); }} </script>
<a href="JavaScript:void(0);" onclick="SetHome(this,'http://www.xyz.com');">設爲首頁</a><a href="JavaScript:void(0);" onclick="AddFavorite('個人網站',location.href)">收藏本站</a><a href="JavaScript:void(0);" onclick=" toDesktop(location.href,'個人網站')">保存到桌面</a>
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
本文分享自微信公衆號 - web前端開發(web_qdkf)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。html