“Sertakan JS ke JS” Kode Jawaban

JavaScript termasuk file js

function loadScript( url, callback ) {
  var script = document.createElement( "script" )
  	  script.type = "text/javascript";
 	  script.onload = function() {
     	callback()
      };
}
// call the function...
loadScript("js/myscript.js", function() {
  alert('script ready!'); 
});
Friendly Hawk

Sertakan file JS lainnya dalam file JS

document.writeln("<script type='text/javascript' src='Script1.js'></script>");
document.writeln("<script type='text/javascript' src='Script2.js'></script>");
Energetic Eland

Sertakan JS ke JS

var imported = document.createElement('script');
imported.src = '/path/to/imported/script';
document.head.appendChild(imported);
Indonesia People

Sertakan JS ke JS

<script type="module">
  import { hello } from './hello.mjs'; // Or it could be simply `hello.js`
  hello('world');
</script>

// hello.mjs -- or it could be simply `hello.js`
export function hello(text) {
  const div = document.createElement('div');
  div.textContent = `Hello ${text}`;
  document.body.appendChild(div);
}
Indonesia People

Jawaban yang mirip dengan “Sertakan JS ke JS”

Pertanyaan yang mirip dengan “Sertakan JS ke JS”

Lebih banyak jawaban terkait untuk “Sertakan JS ke JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya