Prototype with dynamic HTML: style and script
Friday 9 May, 2008Over a year ago I wrote a post (Dynamic HTML with Javascript) that outlined some techniques to dynamically add style sheets and scripts to an HTML page already loaded. Who uses Prototype.js can greatly simplify life by using for instance:
- "dom:loaded" , document. observe ( "Sunday: loaded"
- function () (
- 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!


















