zoukankan      html  css  js  c++  java
  • js加入收藏夹

    工作需要了解了一下点击加入收藏这个功能

    <script>
      function _addFavorite() {
          var url = window.location;
      //获取当前网页网址 var title = document.title;
      //获取当前网页标题 var ua = navigator.userAgent.toLowerCase();
      //获取当前浏览器

      //判断浏览器版本 if (ua.indexOf("360se") > -1) { alert("由于360浏览器功能限制,请按 Ctrl+D 手动收藏!"); } else if (ua.indexOf("msie 8") > -1) { window.external.AddToFavoritesBar(url, title); //IE8
        //加入收藏夹 } else if (document.all) {//IE类浏览器
          document.all是页面内所有元素的一个集合。例如:      
         document.all(0)表示页面内第一个元素
        二.
          document.all可以判断浏览器是否是IE  
            if(document.all){  
                alert("is   IE!");  
           } try{ window.external.addFavorite(url, title);
           }catch(e){ alert('您的浏览器不支持,请按 Ctrl+D 手动收藏!'); } } else if (window.sidebar) {//firfox等浏览器;
          http://www.360doc.com/content/14/0214/15/9494961_352475015.shtml 详情window.sidebar window.sidebar.addPanel(title, url, ""); } else { alert('您的浏览器不支持,请按 Ctrl+D 手动收藏!'); } } </script>   <a href="javascript:void(0)" onclick="_addFavorite()">加入收藏</a>

      

  • 相关阅读:
    Add source code and doc in maven
    Spring toturial note
    How to add local jar into maven project
    Ubuntu 12.04 下安装 Eclipse
    如何更改linux文件的拥有者及用户组(chown和chgrp)
    20非常有用的Java程序片段
    Java中的Set、List、Map的区别
    Java I/O知识点汇总
    Java I/O流整理
    hadoop2.0集群配置
  • 原文地址:https://www.cnblogs.com/lyWebstrat/p/6566616.html
Copyright © 2011-2022 走看看