Set as home page join favorites compatible with all browsers

From , 5 Years ago, written in JavaScript, viewed 143 times.
URL https://pastebin.vip/view/b071cfa8
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>设置为主页 加入收藏 兼容所有浏览器</title>
  6. </head>
  7.  
  8. <body>
  9. <div> <a href="http://yuncode.net">首页</a> | <a onclick="SetHome(window.location)" href="javascript:void(0)">设为主页</a> | <a onclick="AddFavorite(window.location,document.title)" href="javascript:void(0)">加入收藏</a> </div>
  10. <script type="text/javascript" language="javascript">
  11.     //加入收藏
  12.         function AddFavorite(sURL, sTitle) {
  13.             sURL = encodeURI(sURL);
  14.         try{  
  15.             window.external.addFavorite(sURL, sTitle);  
  16.         }catch(e) {  
  17.             try{  
  18.                 window.sidebar.addPanel(sTitle, sURL, "");  
  19.             }catch (e) {  
  20.                 alert("加入收藏失败,请使用Ctrl+D进行添加,或手动在浏览器里进行设置.");
  21.             }  
  22.         }
  23.     }
  24.     //设为首页
  25.     function SetHome(url){
  26.         if (document.all) {
  27.             document.body.style.behavior='url(#default#homepage)';
  28.                document.body.setHomePage(url);
  29.         }else{
  30.             alert("您的浏览器不支持自动设置页面为首页功能,请您手动在浏览器里设置该页面为首页!");
  31.         }
  32.     }
  33. </script>
  34. </body>
  35. </html>
  36.  

Reply to "Set as home page join favorites compatible with all browsers"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website