DOM树添加script脚本和style样式
添加javascript脚本:
如果要添加以下脚本到DOM文档页面中:
var style = document.createElement('style');style.type = 'text/css'; var cssText = "body{background-color:blue;}";try{ style.appendChild(document.createTextNode(cssText));} catch (ex){ style.styleSheet.cssText = cssText;//IE}var head = document.getElementsByTagName('head')[0];head.appendChild(style);