function FixPrototypeForGecko(){
window.navigate=function(url){
location.href=url;
};
HTMLElement.prototype.__defineGetter__("runtimeStyle",element_prototype_get_runtimeStyle);
HTMLTableElement.prototype.__defineGetter__("cells",function(){
if(this._cells==null){
this._cells=Esc.getTableCells(this);
}
return this._cells;
});
//*************begin********************//
/**
HTMLElement.prototype.__defineGetter__("firstChild", element_prototype_get_firstChild);
HTMLElement.prototype.__defineGetter__("lastChild", element_prototype_get_lastChild);
HTMLElement.prototype.__defineGetter__("nextSibling", element_prototype_get_nextSibling);
HTMLElement.prototype.__defineGetter__("previousSibling", element_prototype_get_previousSibling);
*/
//判断是否是firefox
if(navigator.userAgent.indexOf("Firefox")>0){
window.constructor.prototype.__defineGetter__("event",window_prototype_get_event);
}
//**************end*******************//
Event.prototype.__defineGetter__("srcElement",event_prototype_get_srcElement); //得event事件源
Event.prototype.__defineGetter__("fromElement", element_prototype_get_fromElement);
Event.prototype.__defineGetter__("toElement", element_prototype_get_toElement);
//**********begin***************//
// Event.prototype.__defineGetter__("parentElement", element_prototype_get_parentElement);
//**********end***************//
HTMLElement.prototype.fireEvent=function(type,data){
var evt = document.createEvent('Event');
type.replace(/^on/g,type);
evt.initEvent(type,true,true);
evt.data=data;
this.dispatchEvent(evt);
};
}
function element_prototype_get_runtimeStyle() { return this.style; }
function event_prototype_get_srcElement() { return this.target; } //event事件源
function window_prototype_get_event() {
return searchEvent();
}
function element_prototype_get_fromElement() {
var node;
if(this.type == "mouseover") node = this.relatedTarget;
else if (this.type == "mouseout") node = this.target;
if(!node) return;
while (node.nodeType != 1)
node = node.parentNode;
return node;
}
function element_prototype_get_toElement() {
var node;
if(this.type == "mouseout") node = this.relatedTarget;
else if (this.type == "mouseover") node = this.target;
if(!node) return;
while (node.nodeType != 1)
node = node.parentNode;
return node;
}
function searchEvent()
{
if(window.ActiveXObject) return window.event;
func = searchEvent.caller;
while(func!=null){
var arg0=func.arguments[0];
if(arg0 instanceof Event) {
return arg0;
}
func=func.caller;
}
return null;
}
/**
* 交换方法
*/
function swapNode(node1,node2)
{
var parent = node1.parentNode; //父节点
var t1 = node1.nextSibling; //两节点的相对位置
var t2 = node2.nextSibling;
if(t1){
parent.insertBefore(node2,t1);
}else{
parent.appendChild(node2);
}
if(t2){
parent.insertBefore(node1,t2);
}else{
parent.appendChild(node1);
}
}