开发网站 设为首页 加入收藏的代码

<a href=# onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('URL');event.returnValue=false;">设为首页</a>

URL就是你要设定的网址地址

要设置当前网页的地址为首页,你可以这样:

<a href=# onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage(document.location.href);event.returnValue=false;">设为 首页</a>

上述方法采用javascript的document.location对象的href属性来获得当前网页的全路径。

同理,如果您只想将当前网页所在的域名地址设为首页,您只需将document.location.href改为document.location.host即可。示例如下:

<a href=# onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage(document.location.host);event.returnValue=false;">设为 首页</a>

说明:如果当前网页的地址为:http://517712.com/html/zuixinyingshi/xijupian/2009/0326/143.html,则会将当前网页的域名地址(www.517712.com)设为首页。

加入到收藏夹中的实现方法为:

<a href="Javascript:window.external.addFavorite('http://www.517712.com','数字电影')">加入收藏</a>

举一反三,与上面设为首页的方法一样,如果您要将当前网页加入收藏,而当前网页的网址不确定,您可以采用以下方法:

<a href="Javascript:window.external.addFavorite(document.location.href,document.title)">加入收藏</a>

其中的document.title为自动获取当前网页的标题的javascript代码。

用到的代码

document.location.host      //获取网页域名地址

document.location.href      //获取网页完整路径

document.title                   //获取网页的标题

<a target=_top href=javascript:window.external.AddFavorite('http://www.517712.com';,'数字影视基地')>加入收藏</a>

<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('www.517712.com');">设为首页</a>

<P>&lt;a&nbsp;target=_top&nbsp;href=javascript:window.external.AddFavorite('<A href="http://www.517712.com&amp;/" target=_blank>http://www.517712.com&amp;</A>#39;,'<A class=Channel_KeyLink href="http://www.517712.com/">数字影视基地</A>数字影视基地')& gt;加入收藏&lt;/a&gt;</P>

<P><BR>&lt;a&nbsp;href=#& amp;nbsp;onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('www.517712.com');"&gt;设为首页&lt;/a&gt;< /P>

图片链接

<a style="cursor:hand" οnclick="this.style.behavior=’url(#default#homepage)’;

this.setHomePage(’http://ha321.com/bookmark-favorites.php’);">

<img width=16 height=16 border=0 src="images/house.png">

<u> Set as Home Page</u></a>

1.文字型:

<a οnclick="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.ha321.com’);" href="#">設為首頁</a>

範例:

設為首頁

2.按鈕型:

<input TYPE="button" VALUE=" 設為首頁 " οnclick="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.ha321.com’);" href="#">

离开时自动提示设为首页

<body οnunlοad="BASEBody.style.behavior=’url(#default#homepage)’;if(!(BASEBody.isHomePage(’http://ha321.com')))BASEBody.setHomePage(’http://www.ha321.com/’);">

-------------------------------------------------------------

打开页面时自动弹出窗口询问是否设为首页 字串7

将以下代码放在<head></head>之间:

<script language="javascript">

function myhomepage(){

this.homepage.style.behavior=’url(#default#homepage)’;this.homepage.sethomepage(’http://www.ha321.com’);

}

</script>

<p align="center"><a href="http:ha321.com" name="homepage"

οnclick="myhomepage();"></a>

再将下面代码加入<body>内:

οnlοad="myhomepage();"

即:<body οnlοad="myhomepage();">

------------------------------------------------------------------------------

鼠标指向时提示设为首页

将下列代码插入<body>区中:

<A href="http://www.netbei.com/" οnmοuseοver="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.ha321.com’);" target="_blank">设为首页</A>

-------------------------------------------------------------------------------

关闭当前窗口的功能

  这里我们可以先输入用来标示的文字“关闭窗口”,用鼠标拖动选中它,在“Link”输入框中键入“/”,同时切入源代码窗口,在链接代码中键入该事件-οnclick=“javascript:window.close(); return false;”。

字串2

  完整的代码为:< a href=“/”οnclick=“javascript:window.close(); return false;”>关闭窗口< /a>

 

 

文章源网址:http://hi.baidu.com/cate1206/blog/item/7694275842fb2988800a1801.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值