/    Sign up×
Community /Pin to ProfileBookmark

Dynamically insert javascript with IE conditional comment

ie7.js is a javascript that standardises IE browser.

The original usage code

[code=html]<!–[if lt IE 7]>
<script src=”http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js” type=”text/javascript”></script>
<![endif]–>[/code]

How do i insert it dynamically with the Internet Explorer conditional comment into a html file with javascript ?

The code below actually works but I just do not know how to insert the internet explorer conditional comment

[CODE]window.onload=function(){
var script=document.createElement(‘script’);
script.type=”text/javascript”;
script.src=”http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js”;
var head=document.getElementsByTagName(‘head’);
head[0].appendChild(script);
}
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mrhooMay 30.2008 — [CODE]var cc=document.createComment('[if lt IE 7]><script src="http://ie7-js.googlecode.'com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"></script><![endif]');

document.getElementsByTagName('head')[0].appendChild(cc);[/CODE]
×

Success!

Help @Jason7fd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...