欢迎访问 夜阑小雨 我的学习碎片档案,这里记录了我的学习内容和工作中经验,希望给您带去帮助。

代码 设为主页 加入收藏 代码

javascript 夜阑小雨 1105℃ 0评论

设为首页:  

<a href=”#” mce_href=”#” onClick=”this.style.behavior=’url

(#default#homepage)’;this.setHomePage(‘http://www.baidu.com’);”>设为首页</a>  

加入收藏  

<span style=”CURSOR: hand” mce_style=”CURSOR: hand”

onClick=”window.external.addFavorite(‘http://www.baidu.com’,’百度’)” >加入收藏</span>

图片  

设为首页 :
<a href=”#” mce_href=”#” onClick=”this.style.behavior=’url

(#default#homepage)’;this.setHomePage(‘http://www.baidu.com’);”><img border=”0″

src=”Images/About_2.gif” mce_src=”Images/About_2.gif” width=”84″ height=”19″ /></a>  

加入收藏   :

<a href=”#” mce_href=”#”><img border=”0″ src=”images/A_2.jpg” mce_src=”images/A_2.jpg”

width=”150″ height=”39″ id=”shoucang” onClick=”window.external.addFavorite

(‘http://www.baidu.com’,’百度’)” /></a>

支持IE 和FF:

<script>
function addBookmark(){
var tt=document.title
var uu=document.location.href
if (window.sidebar) {
window.sidebar.addPanel(tt, uu,””);
} else if( document.all ) {
window.external.AddFavorite( uu, tt);
} else if( window.opera && window.print ) {
return true;
}
}
</script>

<a href=”#” onclick=”addBookmark();return(false);”>收藏</a>

测试过,可以使用!

在IE6-7. FF2.0 OP9.0中测试通过
———————————————

<script type=”text/javascript”>
// <![CDATA[
function bookmark(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,””);
else if( window.opera && window.print ){
var mbm = document.createElement(‘a’);
mbm.setAttribute(‘rel’,’sidebar’);
mbm.setAttribute(‘href’,url);
mbm.setAttribute(‘title’,title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}
// ]]>
</script>
<a href=”javascript:bookmark()”>加入收藏夹</a>

转载请注明:夜阑小雨 » 代码 设为主页 加入收藏 代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址