Categories
javascript jquery

Dynamic Link Tag Injection

Using jquery to inject a style sheet seems to break IE7/8. The scenario was when a user passed in a custom param via the URL the code would inject that particular css. Ideally I should have gone with the native javascript way to create the element since it’s still clean and simple. This may not be an issue, but for my particular scenario it was the case.

jQuery version:
[code lang=”js” autolinks=”false” classname=”codeClass” collapse=”false” firstline=”1″ gutter=”true” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″]

$(‘head’).append($(‘<link rel="stylesheet" type="text/css" />’)
.attr(‘href’, ‘http://www.somedomain.com/css/cool.css’));

[/code]

RLS is a disorder of the nervous system, though much is still a 100mg viagra for sale mystery about this fairly common condition. To restrict the cholesterol elevation and to protect our heart from getting cialis cheap india seized by the undesired impacts of this disorder. More important things on your list of priorities than having sex. cheap cialis from india As well, it viagra price cloverleafbowl.com supports the erection process by boosting Cyclic GMP. Native version:
[code lang=”js” autolinks=”false” classname=”codeClass” collapse=”false” firstline=”1″ gutter=”true” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″]

var link = document.createElement(‘link’);
link.href = ‘http://www.somedomain.com/css/cool.css’;
link.rel = ‘stylesheet’;
link.type = ‘text/css’;
document.getElementsByTagName(‘head’)[0].appendChild(link);

[/code]