|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧给FF增加了IE专有的属性和办法:
<scriptlanguage="JavaScript"type="Text/JavaScript">
<!--
if(window.Event){//修改Event的DOM
Event.prototype.__defineSetter__("returnValue",function(b){//
if(!b)this.preventDefault();
returnb;
});
Event.prototype.__defineSetter__("cancelBubble",function(b){//设置大概检索以后事务句柄的条理冒泡
if(b)this.stopPropagation();
returnb;
});
Event.prototype.__defineGetter__("srcElement",function(){
varnode=this.target;
while(node.nodeType!=1)node=node.parentNode;
returnnode;
});
Event.prototype.__defineGetter__("fromElement",function(){//前往鼠标移出的源节点
varnode;
if(this.type=="mou搜索引擎优化ver")
node=this.relatedTarget;
elseif(this.type=="mou搜索引擎优化ut")
node=this.target;
if(!node)return;
while(node.nodeType!=1)node=node.parentNode;
returnnode;
});
Event.prototype.__defineGetter__("toElement",function(){//前往鼠标移进的源节点
varnode;
if(this.type=="mou搜索引擎优化ut")
node=this.relatedTarget;
elseif(this.type=="mou搜索引擎优化ver")
node=this.target;
if(!node)return;
while(node.nodeType!=1)node=node.parentNode;
returnnode;
});
Event.prototype.__defineGetter__("offsetX",function(){
returnthis.layerX;
});
Event.prototype.__defineGetter__("offsetY",function(){
returnthis.layerY;
});
}
if(window.Document){//修改Document的DOM
}
if(window.Node){//修改Node的DOM
Node.prototype.replaceNode=function(Node){//交换指定节点
this.parentNode.replaceChild(Node,this);
}
Node.prototype.removeNode=function(removeChildren){//删除指定节点
if(removeChildren)
returnthis.parentNode.removeChild(this);
else{
varrange=document.createRange();
range.selectNodeContents(this);
returnthis.parentNode.replaceChild(range.extractContents(),this);
}
}
Node.prototype.swapNode=function(Node){//互换节点
varnextSibling=this.nextSibling;
varparentNode=this.parentNode;
node.parentNode.replaceChild(this,Node);
parentNode.insertBefore(node,nextSibling);
}
}
if(window.HTMLElement){
HTMLElement.prototype.__defineGetter__("all",function(){
vara=this.getElementsByTagName("*");
varnode=this;
a.tags=function(sTagName){
returnnode.getElementsByTagName(sTagName);
}
returna;
});
HTMLElement.prototype.__defineGetter__("parentElement",function(){
if(this.parentNode==this.ownerDocument)returnnull;
returnthis.parentNode;
});
HTMLElement.prototype.__defineGetter__("children",function(){
vartmp=[];
varj=0;
varn;
for(vari=0;i<this.childNodes.length;i++){
n=this.childNodes;
if(n.nodeType==1){
tmp[j++]=n;
if(n.name){
if(!tmp[n.name])
tmp[n.name]=[];
tmp[n.name][tmp[n.name].length]=n;
}
if(n.id)
tmp[n.id]=n;
}
}
returntmp;
});
HTMLElement.prototype.__defineGetter__("currentStyle",function(){
returnthis.ownerDocument.defaultView.getComputedStyle(this,null);
});
HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
varr=this.ownerDocument.createRange();
r.setStartBefore(this);
vardf=r.createContextualFragment(sHTML);
this.parentNode.replaceChild(df,this);
returnsHTML;
});
HTMLElement.prototype.__defineGetter__("outerHTML",function(){
varattr;
varattrs=this.attributes;
varstr="<"+this.tagName;
for(vari=0;i<attrs.length;i++){
attr=attrs;
if(attr.specified)
str+=""+attr.name+"=""+attr.value+""";
}
if(!this.canHaveChildren)
returnstr+">";
returnstr+">"+this.innerHTML+"</"+this.tagName+">";
});
HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
switch(this.tagName.toLowerCase()){
case"area":
case"base":
case"basefont":
case"col":
case"frame":
case"hr":
case"img":
case"br":
case"input":
case"isindex":
case"link":
case"meta":
case"param":
returnfalse;
}
returntrue;
});
HTMLElement.prototype.__defineSetter__("innerText",function(sText){
varparsedText=document.createTextNode(sText);
this.innerHTML=parsedText;
returnparsedText;
});
HTMLElement.prototype.__defineGetter__("innerText",function(){
varr=this.ownerDocument.createRange();
r.selectNodeContents(this);
returnr.toString();
});
HTMLElement.prototype.__defineSetter__("outerText",function(sText){
varparsedText=document.createTextNode(sText);
this.outerHTML=parsedText;
returnparsedText;
});
HTMLElement.prototype.__defineGetter__("outerText",function(){
varr=this.ownerDocument.createRange();
r.selectNodeContents(this);
returnr.toString();
});
HTMLElement.prototype.attachEvent=function(sType,fHandler){
varshortTypeName=sType.replace(/on/,"");
fHandler._ieEmuEventHandler=function(e){
window.event=e;
returnfHandler();
}
this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
}
HTMLElement.prototype.detachEvent=function(sType,fHandler){
varshortTypeName=sType.replace(/on/,"");
if(typeof(fHandler._ieEmuEventHandler)=="function")
this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
else
this.removeEventListener(shortTypeName,fHandler,true);
}
HTMLElement.prototype.contains=function(Node){//是不是包括某节点
doif(Node==this)returntrue;
while(Node=Node.parentNode);
returnfalse;
}
HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){
switch(where){
case"beforeBegin":
this.parentNode.insertBefore(parsedNode,this);
break;
case"afterBegin":
this.insertBefore(parsedNode,this.firstChild);
break;
case"beforeEnd":
this.appendChild(parsedNode);
break;
case"afterEnd":
if(this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else
this.parentNode.appendChild(parsedNode);
break;
}
}
HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){
varr=this.ownerDocument.createRange();
r.setStartBefore(this);
varparsedHTML=r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML);
}
HTMLElement.prototype.insertAdjacentText=function(where,txtStr){
varparsedText=document.createTextNode(txtStr);
this.insertAdjacentElement(where,parsedText);
}
HTMLElement.prototype.attachEvent=function(sType,fHandler){
varshortTypeName=sType.replace(/on/,"");
fHandler._ieEmuEventHandler=function(e){
window.event=e;
returnfHandler();
}
this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
}
HTMLElement.prototype.detachEvent=function(sType,fHandler){
varshortTypeName=sType.replace(/on/,"");
if(typeof(fHandler._ieEmuEventHandler)=="function")
this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
else
this.removeEventListener(shortTypeName,fHandler,true);
}
}
//-->
</script>
举个例子,在FF中利用currentStyle
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="cn"lang="cn">
<head>
<styletype="text/CSS">
#a{width:100px;height:100px;background-color:yellow;}
</style>
<scripttype="text/javascript">
window.onload=function(){
HTMLElement.prototype.__defineGetter__("currentStyle",function(){returnthis.ownerDocument.defaultView.getComputedStyle(this,null);});
//下面一行代码就给一切的HTML元素增加了currentStyle属性
vara=document.getElementById("a");
alert("style中的width=""+a.style.width+"" currentStyle中的width=""+a.currentStyle.width+""");
}
</script>
</head><body>
<divid="a"></div>
</body>
</html>
SQLServer是基于服务器端的中型的数据库,可以适合大容量数据的应用,在功能上管理上也要比Access要强得多。在处理海量数据的效率,后台开发的灵活性,可扩展性等方面强大。 |
|