Skip to content

Instantly share code, notes, and snippets.

@xincici
Created March 3, 2015 07:30
Show Gist options
  • Save xincici/cf7aced5d838fd91d708 to your computer and use it in GitHub Desktop.
Save xincici/cf7aced5d838fd91d708 to your computer and use it in GitHub Desktop.
run script string
//运行插入页面的javascript代码
function loadScriptString(s){
var a = document.createElement('script');
a.type = 'text/javascript';
var t = document.createTextNode(s);
try{
a.appendChild(t);
}catch(e){
a.text = s;
}
document.getElementsByTagName('head')[0].appendChild(a);
}
loadScriptString('alert(1)');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment