- function loadScriptString(code){
- var script = document.createElement('script');
- script.type = 'text/javascript';
- try{
- script.appendChild(document.createTextNode(code));
- } catch (ex){
- script.text =code;
- }
- document.body.appendChild(script);
- }
- loadScriptString("function sayHi() { alert('hello'); }");
- function loadJsorCSS(url,type){
- type =type ||'js';
- if(type == 'js' && url){
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = url;
- document.body.appendChild(script);
- }
- // <link rel="stylesheet" type="text/css" );
- //该片段来自于http://www.codesnippet.cn/detail/0810201513762.html
来源: http://www.codesnippet.cn/detail/0810201513762.html