Prevent javascript enable in IE6

I would like to hear your thoughts on this particular issue:

I use the functionality of the LinkedIn button, and this comes about:

<script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/MemberProfile" data-id="http://www.linkedin.com/pub/profile" data-format="click" data-text="LinkedIn Profile"></script>

The only problem is that it works very poorly in IE6, so all I want to do is hide this button in IE6, I thought about using it <!--[if gte IE 7]>Javascript code here<![endif]-->, but it would also prevent it from loading in any other browser than IE, another option is to use jquery: if($.browser.msie && $.browser.version=="6.0"){ }but how do I do this with javascript SRC files?

Any thoughts? Thank!

+3
source share
5 answers

You say you tried this:

<!--[if gte IE 7]>Javascript code here<![endif]-->

As you say, this will prevent browsers other than IE from viewing the script.

, . , , , , :

<![if gte IE 7]>Javascript code here<![endif]>

, IE, IE7.

. http://en.wikipedia.org/wiki/Conditional_comment.

(, , , , IE6 - )

+3

<!--[if ! lte IE 6]>Javascript code here<![endif]-->

-

<!--[if (!IE)|(IE gt 6)]>Javascript code here<![endif]-->
0
if(! IE6){
    var script = document.createElement("script");
    script.src = "src_to_js_file";
    document.body.appendChild(script);
}

or just use innerHTML to add two script tags to the DOM.

0
source

You can use jQuery method getScript

if(!($.browser.msie && $.browser.version=="6.0"))
    $.getScript('http://platform.linkedin.com/in.js');
0
source
if($.browser.msie && $.browser.version=="6.0"){
  $('head').append('<script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/MemberProfile" data-id="http://www.linkedin.com/pub/profile" data-format="click" data-text="LinkedIn Profile"></script>')
}
0
source

All Articles