-
-
Save l/1342587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*@cc_on @*/ | |
/* if IE, do nothing (error 8004004, whatever that is) */ | |
/*@if (@_jscript_version > 0) | |
@else @*/ | |
document.getCurrentScript = function(){ | |
// fails when document.write nests like | |
// document.write('<'+'script'+'>' +'document.write(...)' + '</'+'script'+'>') | |
return (function (e) { | |
if (!e) return null // gracefully report failure | |
if (e.nodeName.toLowerCase() == 'script') return e; | |
return arguments.callee(e.lastChild) | |
})(document) | |
}; | |
document.__write__ = document.write; | |
document.write = function (what, where) { | |
if (!where) where = this.getCurrentScript(); | |
if (!where) return this.__write__(what); | |
var here = where.previousSibling; | |
if (!here || here.nodeType != 1 || here.className != '.written'){ | |
here = document.createElement('div'); | |
here.className = '.written'; | |
where.parentNode.insertBefore(here, where); | |
} | |
if (what.nodeType){ | |
here.appendChild(what); | |
}else{ | |
if (what.match(/^<script/i)){ | |
// needed to have your browser reevaluate the script | |
this.__write__(what); | |
} | |
else{ | |
var tmp = here.innerHTML; | |
try{ | |
here.innerHTML += what; | |
}catch(e){ | |
here.innerHTML = tmp; | |
if (here.namespaceURI == 'http://www.w3.org/1999/xhtml'){ | |
do{ | |
what = what.replace(' ', ' '); | |
}while(what.indexOf(' ')>=0) | |
here.innerHTML += what; | |
} | |
else { | |
alert(e); | |
} | |
} | |
} | |
} | |
}; | |
/*@end @*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2ndtest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment