子风.NET 进阶中......

路途多艱,唯勤是岸

 

动态的添加JS代码

     在qq群上,网友讨论的,觉得不错,收藏一下。

1 function executeJS(jsCode)
            {
                var jsIframe = document.createElement("iframe");
                jsIframe.style.display = "none";//把jsIframe隐藏起来
                document.body.appendChild(jsIframe);
                with(window.frames[window.frames.length - 1]){
                    document.open();
                    document.write(jsCode); //执行JS代码
                    document.close();
                }
                document.body.removeChild(jsIframe);//执行后删除iframe对象
            }

 

 var js = document.createElement("script");
        js.type = "text/javascript";
        js.src = "/js/Script.js";
        document.body.appendChild(js);

posted on 2009-03-10 14:20  子风  阅读(979)  评论(0)    收藏  举报

导航