加入收藏代碼

來源:互聯網
上載者:User
超級設為首頁,加入收藏代碼,自動識別網域名稱,和收藏名稱

<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>&lt;a&nbsp;target=_top&nbsp;href=javascript:window.external.AddFavorite('<A href="http://www.mtv555.com&amp;/" target=_blank>http://www.ha321.com&amp;</A>#39;,'<A class=Channel_KeyLink href="http://www.ha321.com/">MTV音樂站</A>mtv音樂站ha321.com')&gt;加入收藏&lt;/a&gt;</P>

<P><BR>&lt;a&nbsp;href=#&nbsp;onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('www.ha321.com');"&gt;設為首頁&lt;/a&gt;</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>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.