'加入收藏' 功能
来源:互联网 发布:csgo 手机 检视 软件 编辑:程序博客网 时间:2024/04/29 23:48
第一种写法:例子
<a href="javascript:void(0);" target="_self" onclick="javascript:try{ window.external.AddFavorite('http://www.butao.com','步淘'); } catch(e){ (window.sidebar)?window.sidebar.addPanel('360安全网址','http://hao.360.cn/',''):alert('请使用按键 Ctrl+d,收藏360安全网址'); }">加入收藏</a>
第二种写法:例子
<a href="#" onclick="addfavorite()">加入收藏!</a><script> function addfavorite(){ if (document.all){ window.external.addFavorite('http://www.baidu.com','收藏夹'); } else if (window.sidebar){ window.sidebar.addPanel('百度一下', 'http://www.baidu.com', ""); } else { alert( "请使用 Ctrl+D 进行添加" ); } }</script>
第三种写法:例子
<a href="javascript:;" onclick="AddFavorite('http://www.butao.com','butao')">把www.butao.com加入收藏</a><script> function AddFavorite(sURL, sTitle){ try{ window.external.addFavorite(sURL, sTitle); } catch (e){ try{ window.sidebar.addPanel(sTitle, sURL, ""); } catch (e){ alert("加入收藏失败,请使用Ctrl+D进行添加"); } } }</script>
第四种写法:例子
<a href="javascript:;" onclick="javascript:addfavor(' http://www.butao.com','butao');">加入收藏</a><script language="javascript"> function addfavor(url,title) { if(confirm("网站名称:"+title+"n网址:"+url+"n确定添加收藏?")){ var ua = navigator.userAgent.toLowerCase(); if(ua.indexOf("msie 8")>-1){ external.AddToFavoritesBar(url,title,'butao'); //IE8 }else{ try { window.external.addFavorite(url, title); } catch(e) { try { window.sidebar.addPanel(title, url, ""); //firefox } catch(e) { alert("加入收藏失败,请使用Ctrl+D进行添加"); } } } } return false; }</script>
第五种写法:例子
<a href="javascript:void();" onclick="addfavorite()">将本页加入收藏</a><script language="javascript">var isIE =(document.all&&document.getElementByIdx_x_x_x_x_xx_x&&!window.opera)?true:false;var isMozilla=(!document.all&&document.getElementByIdx_x_x_x_x_xx_x&&!window.opera)?true:false;var weburl=window.location.href;var webname=document.title;function addfavorite(){ if(isMozilla){ if (document.all){ window.external.addFavorite(weburl,webname); }else if(window.sidebar){ window.sidebar.addPanel(webname,weburl,""); } } if(isIE){ window.external.AddFavorite(weburl, webname); }}</script>
第六种写法:使用图片实现加入收藏的效果:
<a onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.baidu.com');" href="javascript:;" title="设为首页"><img src="Images/about_2.gif" border="0" width="84" height="19" title="设为首页" /></a>
0 0
- 加入收藏功能
- '加入收藏' 功能
- 加入收藏功能函数
- 加入收藏
- 加入收藏
- 加入收藏
- 加入收藏
- 加入收藏
- 加入收藏
- 设为首页和加入收藏的功能
- 页面功能:设为首页和加入收藏
- Js实现设为首页和加入收藏功能
- jsp页面功能:设为首页和加入收藏
- javascript: 加入收藏 设为首页 功能 兼容Firefox和IE
- 如何实现"设为首页","加入收藏"的功能
- 如何实现"设为首页","加入收藏"的功能
- 用jQuery实现简单的加入收藏页面的功能
- 用jQuery实现简单的加入收藏页面的功能
- 斜率优化DP(hdu3507)
- 【iOS提高】CoreAnimation--Layer
- Kafka 安装和测试
- UVA11995 优先队列
- c#多线程与异步开发 (下)
- '加入收藏' 功能
- 2016.1.29
- 工具类——验证码
- 体绘制之光线投射算法(附源码)
- C语言学习笔记 类型修饰符
- dede标签loop,万能循环
- MIT图像目标跟踪Matlab完整版
- BZOJ 4292 [PA2015]Równanie 水题
- window对象