m 1 révision importée |
Aucun résumé des modifications |
||
Ligne 1 : | Ligne 1 : | ||
<keywords content="Javascript"/> | <keywords content="Javascript"/> | ||
== Charger dynamiquement un script == | |||
{{syntaxhighlight | lang=javascript | code= | |||
//comment charger dynamiquement un script | |||
function loadscript(url, callback) | |||
{ | |||
// adding the script element to the head as suggested before | |||
var head = document.getElementsByTagName('head')[0]; | |||
var script = document.createElement('script'); | |||
script.type = 'text/javascript'; | |||
script.src = url; | |||
// then bind the event to the callback function | |||
// there are several events for cross browser compatibility | |||
script.onreadystatechange = callback; | |||
script.onload = callback; | |||
// fire the loading | |||
head.appendChild(script); | |||
} | |||
}} | |||
== Liens Externes == | == Liens Externes == | ||
{{grebox-jck|content= | {{grebox-jck|content= |
<keywords content="Javascript"/>