I have implemented addthis javascript in my code.
But if I open my page in IE 7, it will not work.
So, I am trying to add that script only if the browser is not IE 7
First I wrote this code and it works.
<!--[if IE 7]>
<script type="text/javascript">
alert('hihi');
</script>
<![endif]-->
That code works and the page will show hihi in IE 7 but not in other browsers.
Now, I want to reverse this and make the page show hihi only if the browser is not IE 7
I tried
<!--[if !IE 7]>
<script type="text/javascript">
alert('hihi');
</script>
<![endif]-->
But it doesn’t work. Is there any other way?
Thanks.
The problem with your code is that to non-IE browsers, it just looks like a normal HTML comment and therefore the script is not included. One option is to create a variable that you check against in your script: