追加脚本在IE中不起作用

我正在使用此脚本来动态添加将脚本加载到我的页面中的脚本。 此代码在Chrome,Safari和FF中正常工作,但不在IE(!!)中。

$.post("shorts.server.php", $.param({

    S_number: stocknumber,

}), function(response) {

    script = document.createElement('script');
    //dynamic_graph.js changes it's content by the current selected stock
    script.src = 'jQuery/head/dynamic_graph.js';
    $("#graphMain" + id).append(script);

    var head = document.getElementsByTagName('body')[0];
    script = document.createElement('script');

    script.src = 'jQuery/head/dynamic_info.js';

    head.appendChild(script);
});​
  1. you can see that I tried both techniques to append the scripts dynamically.
  2. they both don't work in IE. can you suggest a better way to append the scripts? 1 more less important but related question:
    1. what is the currect way to post a script in stackoverflow??, because sometimes it's colored and sometimes it's grayed...
0
额外 编辑
意见: 1
红色代表字符串。
额外 作者 Jivings,

1 答案

当我在前段时间尝试在IE中向DOM追加动态元素时,我发现我需要反过来才能使其工作。所以,而不是

$("#graphMain" + id).append(script);

尝试

$(script).appendTo($("#graphMain" + id));
0
额外
哎呀,我会更新答案!
额外 作者 Graham Clark,
嗨克拉克,谢谢你的回复。我尝试了它,它与“script.appendTo不是一个函数”
额外 作者 devmonster,
谢谢。但那也行不通。我在这里阅读了很多帖子(如[链接] stackoverflow.com/questions/7090198/… 和[link] stackoverflow.com/questions/436710/… ),但我需要将脚本附加到body标签,而且我需要做很多次,每次用户按下一行
额外 作者 devmonster,