をロードしている外部JSファイルから、体内の関数を呼び出す:私は外部JSファイル持って動的に
console.log("DEBUG1");
function Function1() {
console.log("DEBUG2");
}
function Function2() {
console.log("DEBUG3");
}
を、私は、これは頭の中でdinamicallyファイルとその関数の機能1を呼び出すJSロードしたいですbodyのonLoadイベントが発生する前に、bodyの内部で()を呼び出します。 Here、私はall these solutionsを試しました:最初のものだけが動作しますが、私はそれを避けたいと思います。例えば、溶液2は
されています:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript"></script>
<script type="text/javascript">
document.getElementsByTagName("head")[0].getElementsByTagName("script")[0].src = "JS.js";
</script>
</head>
<body onLoad="javascript:Function2();">
<script type="text/javascript">
Function1();
</script>
</body>
</html>
は、どのように私は(溶液1を使用せずに)この問題を解決することができますか?
:私はここでテストとして、私は、本文の最後に到着する前に、JSを読み込むために終了しますます。http://lucaghio.webege。 com/Prova5/2/2.html – cassiodoroVicinetti