添加到收藏夹:
<html>
<head>
<title>bookmark</title>
<script type="text/javascript">
//<![CDATA[
function bookmark(anchor){
if(window.external)
{
window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
return false;
}
return true;
}
//]]>
</script>
</head>
<body>
<a href="http://www.google.com/" rel="sidebar" title="Google" onclick="return bookmark(this)">Bookmark</a>
</body>
</html>
在 <a> 中设置rel属性为 sidebar 可以在firefox中实现添加到收藏夹的功能,其中title属性值是默认书签名,href是书签地址(内容)。
============================================================
============================================================
事件处理:
<script>
if(window.addEventListener)
{
FixPrototypeForGecko();
}
function FixPrototypeForGecko()
{
HTMLElement.prototype.__defineGetter__("runtimeStyle",element_prototype_get_runtimeStyle);
window.constructor.prototype.__defineGetter__("event",window_prototype_get_event);
Event.prototype.__defineGetter__("srcElement",event_prototype_get_srcElement);
}
function element_prototype_get_runtimeStyle()
{
//return style instead...
return this.style;
}
function window_prototype_get_event()
{
return SearchEvent();
}
function event_prototype_get_srcElement()
{
return this.target;
}
function SearchEvent()
{
//IE
if(document.all)
return window.event;
func=SearchEvent.caller;
while(func!=null)
{
var arg0=func.arguments[0];
if(arg0)
{
if(arg0.constructor==Event)
return arg0;
}
func=func.caller;
}
return null;
}
</script>
<button onclick="alert(event.clientX)">OK</button>
将以上代码copy到你的页面中,则可以在firefox的js函数中直接使用event来引用事件对象.
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=318440