---
title: "“收藏本站” 的代码"
author: "liomao"
date: "2010-12-21T17:13:23Z"
tags: ["C", "C#", "C++", "IE", "JavaScript"]
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2010-12-21T17:13:23Z"
id: 848443
url: "https://liomao.iteye.com/blog/848443"
---

网上很多的代码只能在IE中，这个代码能够在 IE 和火狐浏览器中通用。

 

```
<script type="text/javascript">  
function addFavorite() {  
     var c = "http://sise.sinaapp.com/";  
     var b = "华软微博";  
     try {  
         window.external.AddFavorite(c, b)  
     } catch (d) {  
         window.sidebar.addPanel(b, c, "")  
     }  
 };  
</script> 
```

 

html 代码为：

 

```
<!-----------By Amolee---------添加收藏---------------------->			
<a href='#' onClick="addFavorite();">收藏本站</a>
```

 

效果见：[http://sise.sinaapp.com/](http://sise.sinaapp.com/)