Comment insérer

Autres conseils

Si vous voulez inclure JavaScript dans la tête, vous pourriez faire quelque chose comme ceci:

$$('head').first().insert({
    bottom: new Element('script', {
        type: 'text/javascript'
    }).update('function helloWorldToConsole(){console.log("Hello World!")}')
});

Cela crée une nouvelle balise SCRIPT et il insère au fond de votre tête. Mais il serait beaucoup plus agréable si vous ajoutez un fichier JavaScript externe comme ceci:

$$('head').first().insert({
    bottom: new Element('script', {
        type: 'text/javascript',
        src: 'http://www.example.com/path/file.js'
    })
});

Vous pouvez utiliser les fonctions que plus tard dans vos scripts.

essayer ..

    $('<script></script>',{
     type:'custom',
     id:'script1'
    }).appendTo('head').attr('type','text/javascript');

    $('#script1').append(< add js code here >);

});

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top