开发者

Adding script tag to document IE7 issue

开发者 https://www.devze.com 2023-03-24 16:24 出处:网络
My page throws an error in IE7 when I appending an script tag the body. The error occurs on the line that is commented:

My page throws an error in IE7 when I appending an script tag the body.

The error occurs on the line that is commented:

<script type="text/javascript">

cmSetClientID("90065468", false,"www9.blah.com","blah.com");  

 //--> 

</script>

This is how I append the script:

var scriptHolder = document.createElement('script'),
            body = window.parent.document.getElementsByTagName开发者_如何学JAVA('body')[0],
            fn =    "function doMyFn(){//dosomething}";
        scriptHolder.text = fn;
        body.appendChild(scriptHolder);
        window.parent.doMyFn();


Note: body tag schould be much easier to get: document.body

Another thing is to use yourelement.innerHTML to set the content. If you are ao a normal page (no iframe etc...) doMyFn(); should be enough to call your Fn

Hope this helps you

0

精彩评论

暂无评论...
验证码 换一张
取 消