1、实现“设为首页”、“添加到收藏夹”
设置为首页:
<a href=""#"" onClick=""this.style.behavior=’ur(#default#homepage)’;this.setHome
Page('http://www.cnblogs.com/hhasp');"">设为首页</a>
添加收藏:
<a href=""javascript:window.external.AddFavorite(’http://www.cnblogs.com/hhasp’, ’
ToNorth{学习型博客}’)"">添加收藏</a>
但是为了兼容不同的浏览器,得需要修改如下:
<script type=""text/javascript"">
<!--
function myAddPanel(title,url,desc){
if ((typeof window.sidebar == ’object’) && (typeof window.sidebar.addPanel == ’function’))//Gecko
{
window.sidebar.addPanel(title,url,desc);
}
else//IE
{
window.external.AddFavorite(url,title);
}
}
//-->
</script>
<a href=""javascript:myAddPanel(’To North{学习型博客}’,’http://www.cnblogs.com/hhasp/’,’To Torth{学习型博客}’)"" title=""ToNorth{学习型博客}个人网站"">添加收藏</a>
2、怎样隐藏在状态栏里出现的LINK信息?
当你指向一个链接时,该链接的信息会出现在浏览器状态栏里,如果需要隐藏信息,可以如下设置:
<a href="http://www.cnblogs.com/hhasp" onMouseOver=""window.status=’none’;return true"" >隐藏LINK信息</a >
3、JS事件对WMP的影响问题。
在网页中播放WMP时,当触发JS事件时,比如<a href=""javascript:..."">,会使WMP停止播放,把href改为onclick即可。
4、禁止鼠标右键弹出菜单。
function click() {if (event.button==2) {alert(’禁止鼠标右键弹出菜单!’);}}
document.onmousedown=click
5、用JS载入CSS文件。
这里提供一个JS函数:
setActiveStyleSheet(cssfile);
function setActiveStyleSheet(cssfile){
var head=document.getElementsByTagName(""head"");
var es=document.createElement(""link"");
es.href=’css/’+cssfile;
es.rel=""stylesheet"";
es.type=""text/css"";
head[0].appendChild(es);}
浙公网安备 33010602011771号