Portál AbcLinuxu, 29. října 2025 23:10
Ahoj,
mám soubor index.html ve kterém načítám soubor main.js
<script type="text/javascript" src="main.js"></script>
Dále mám několik souborů ve kterých jsou funkce například v souboru test1.js
mám
function aaa(){
console.log('aaa');
}
function bbb(){
console.log('bbb');
}
jak můžu soubory s funkcemi načíst aby s nimi mohl JS script pracovat?
Díky
Řešení dotazu:
<script type="text/javascript" src="test1.js"></script>
<script type="text/javascript" src="main.js"></script>
document.head.appendChild("test1.js");
popr. dalsi reseni (vcetne eval:) zde - https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.