Adding script tag to document IE7 issue
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
精彩评论