100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 网站设为首页 加入收藏夹

网站设为首页 加入收藏夹

时间:2023-10-22 22:56:14

相关推荐

网站设为首页 加入收藏夹

<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>

说明:如果当前网页的地址为:/indexnews.htm,则会将当前网页的域名地址()设为首页。

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

<a href="Javascript:window.external.addFavorite('','易远网络')">加入收藏</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('';,'易远网络')>加入收藏</a>

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

<P>&lt;a&nbsp;target=_top&nbsp;href=javascript:window.external.AddFavorite('<A href="/" target=_blank></A>#39;,'<A class=Channel_KeyLink href="/">济宁网站建设</A>易远网络')&gt;加入收藏&lt;/a&gt;</P>

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

图片链接

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

this.setHomePage(’/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(’’);" href="#">設為首頁</a>

範例:

設為首頁

2.按鈕型:

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

离开时自动提示设为首页

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

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

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

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

<script language="javascript">

function myhomepage(){

this.homepage.style.behavior=’url(#default#homepage)’;this.homepage.sethomepage(’’);

}

</script>

<p align="center"><a href="" name="homepage"

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

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

οnlοad="myhomepage();"

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

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

鼠标指向时提示设为首页

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

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

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

关闭当前窗口的功能

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

字串2

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

以上内容转摘自:(易远网站技术网)→更多精彩内容和详细出处请参考:/content/619121521.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。