0

外部JSファイルの内容をhtmlファイルに書き込む関数を書くJavaScriptを介して関数を実行できるかどうか疑問に思っています。

こんな感じです:

    function insertInlineScript (path){
            var readScriptFromPath (path){
            return "<script>" + scriptContents + "</script>";
            }
    }

次に、これを私のページに挿入するだけです

    insertInlineScript("/path/to/file");
    insertInlineScript("/path/to/file_2");

ページの出力は次のようになります

    <script>
            //contents of first file
    </script>
    <script>
            //contents of 2nd file
    </script>
4

1 に答える 1