Dynamic HTML with Prototype: styles and scripts

Over a year ago I wrote a post ( Dynamic HTML with JavaScript ) which illustrated some techniques to dynamically add stylesheets and scripts in an HTML page loaded. Who uses prototype.js can greatly simplify your life by using, for example:

1
2
3
4
5
6
"dom:loaded" , document. observe ("Sun: loaded",
function () {
new Element ( "script" , { type : "text/javascript" , src : "/js/altro.js" } ) ; var script = new Element ("script", {type: "text / javascript" src "/ js / altro.js"});
) [ 0 ] . insert ( script ) ; $ $ ("Head") [0]. Insert (script);
}
);

After the page is loaded ( document.observe ) adds a new script JavaScript! For styles that is exactly the same thing!

There are no comments for this post

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL