超級設為首頁,加入收藏代碼,自動識別網域名稱,和收藏名稱
<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://www.design007.com/design/index.htm,則會將當前網頁的網域名稱地址(www.design007.com)設為首頁。
加入到收藏夾中的實現方法為:
<a href="Javascript:window.external.addFavorite('http://www.design007.com','設計007')">加入收藏</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.ha321.com';,'MTV音樂站')>加入收藏</a>
<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('www.ha321.com');">設為首頁</a>
<P><a target=_top href=javascript:window.external.AddFavorite('<A href="http://www.mtv555.com&/" target=_blank>http://www.ha321.com&</A>#39;,'<A class=Channel_KeyLink href="http://www.ha321.com/">MTV音樂站</A>mtv音樂站ha321.com')>加入收藏</a></P>
<P><BR><a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('www.ha321.com');">設為首頁</a></P>
圖片連結
<a style="cursor:hand" onclick="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 onclick="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.ha321.com’);" href="#">設為首頁</a>
範例:
設為首頁
2.按鈕型:
<input TYPE="button" VALUE=" 設為首頁 " onclick="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.ha321.com’);" href="#">
離開時自動提示設為首頁
<body onunload="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"
onclick="myhomepage();"></a>
再將下面代碼加入<body>內:
onload="myhomepage();"
即:<body onload="myhomepage();">
------------------------------------------------------------------------------
滑鼠指向時提示設為首頁
將下列代碼插入<body>區中:
<A href="http://www.netbei.com/" onmouseover="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.ha321.com’);" target="_blank">設為首頁</A>
-------------------------------------------------------------------------------
關閉當前視窗的功能
這裡我們可以先輸入用來標示的文字“關閉視窗”,用滑鼠拖動選中它,在“Link”輸入框中鍵入“/”,同時切入原始碼視窗,在連結代碼中鍵入該事件-onclick=“javascript:window.close(); return false;”。
字串2
完整的代碼為:< a href=“/”onclick=“javascript:window.close(); return false;”>關閉視窗< /a>