内部HTML将两个javascript <script>请求合并为一个</script>

时间:2015-03-03 16:50:50

标签: javascript html

我正在使用的系统仅限于支持一个脚本包含。 我的脚本如下所示:

<script type="text/javascript">
var TPR_customization = {
    id: "Thisismyscriptid",
    usecssplayer: false,
    startmuted: true,
    showmute: true,
    autoreplay: true,
    waterfallplaythrough: true,
    showclicktext: false,
    startclosehidden: false
} 
</script>

<script id="tprTag" type="text/javascript" src="
http://requiredbasejavascode.com/locationoffile/file.jsp"></script>

如果我无法编辑第二部分,如何将其合并为一个电话?我讨厌使用iframe。

1 个答案:

答案 0 :(得分:1)

<script type="text/javascript">
    var TPR_customization = {
        id: "Thisismyscriptid",
        usecssplayer: false,
        startmuted: true,
        showmute: true,
        autoreplay: true,
        waterfallplaythrough: true,
        showclicktext: false,
        startclosehidden: false
    }

    var script  = document.createElement("script");
    script.type = "text/javascript"; // not needed for html5
    script.src  = "http://requiredbasejavascode.com/locationoffile/file.jsp";
    script.id   = "tprTag";
    document.body.appendChild(script);
</script>

<强> Read more