kissy 中的eval实现一则

没必要废话.一看就明白. [javascript] globalEval: function(data) { if (data && REG_NOT_WHITE.test(data)) { // Inspired by code by Andrea Giammarchi // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html var head = doc.getElementsByTagName('head')[0] || doc.documentElement, script = doc.createElement('script'); // It works! All browsers support! script.text = data; // Use insertBefore instead of appendChild to circumvent an IE6 bug. // This arises when a base node is used. head.insertBefore(script, head.firstChild); head.removeChild(script); } } [/javascript]
posted @ 2010-09-16 22:19  7hihi  阅读(167)  评论(0编辑  收藏  举报