<script type="text/javascript">
<!--
Function.prototype.method=function(name,fn){
if(!this.prototype[name]){
this.prototype[name]=fn;
return this;
}
}
String.method("aa",function(){
alert(‘ffff‘);
});
String.method("entityify",function(){
var g={
"<":"<",
">":">",
"&":"&",
‘"‘:"""
};
return this.replace(/[<>&\"]/g,function(c){
alert(c);
return g[c];
});
});
alert("<ga&".entityify()); //显示<ga&
//-->
</script>
时间: 2024-10-23 13:44:56