ASp.net c# sql

May 6, 2008

– How to Dynamically Insert Javascript And CSS

<span style=”font-weight:bold;”>This is a short and sweet little tutorial to show you how to dynamically insert a new Javascript (or style sheet) into your web pages</span>

FOR CSS…
var headID = document.getElementsByTagName(“head”)[0];
var cssNode = document.createElement(‘link’);
cssNode.type = ‘text/css’;
cssNode.rel = ‘stylesheet’;
cssNode.href = ‘FireFox.css’;
cssNode.media = ‘screen’;
headID.appendChild(cssNode);

FOR JAVASCRIPT…
var headID = document.getElementsByTagName(“head”)[0];
var newScript = document.createElement(‘script’);
newScript.type = ‘text/javascript’;
newScript.src = ‘http://www.somedomain.com/somescript.js&#8217;;
headID.appendChild(newScript);

Blog at WordPress.com.