如果用户是来自搜索引擎,提示加入收藏夹的代码

<script type="text/javascript">
<!--
shq={};
shq.isSearch=/(baidu|yahoo|google|sogou|zhongsou)\.(cn|com|net)/.test(document.referrer)
shq.isIE=window.ActiveXObject ? true : false;
shq.isFirefox=(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
shq.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
shq.AddFavorite=function()
{
    if(shq.isIE){
         window.external.AddFavorite(location.href,document.title)
        }else if(shq.isFirefox)
        {
         window.sidebar.addPanel(document.title,location.href,"");
        }else
        {
      alert('AddFavorite to your panel? CTRL+T')
        }
        return tmp;
}
if(shq.isSearch){shq.AddFavorite()}
//-->
</script>

你可能感兴趣的:(搜索引擎)