[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

IE Conditional Statement to disable a specific script (IE8 only)

I'm a complete newbie/rookie in web design, but I have come across an issue for one of my sites that I'm currently designing. I saw that 2 similar questions were posted on stackoverflow (one being spot on), but I wasn't able to discern the answer...probably because I'm not very advanced.

I want to know...is there a way to disable a specific script within an IE8-only conditional statement?

Let me explain: I have a rounded corner script that works absolutely beautifully in Firefox, Safari, and IE9. However in IE8, if the background of the parent div is an image (which they all are in this case), the rounded corners fail to appear transparent and instead show as annoying little white fill. (My site is http://gkplusjm.com)

I was able to find some great CSS code that I could implement for IE8, and I have successfully done so in a ie8.css file through a IE conditional statement. I know it works because when I removed the corner script completely and viewed the page with the ie8.css, it was acceptable enough for my liking. However, I put the script back in so it would function on all other browsers, and the problem reared its head again. So what I really need is to find a way to disable that script, but only if the viewer is using IE8. Seems simple enough, but I can't find the fix. Some of the codes I have tried include:

<!--[if lt IE 9]>
<script src="scripts/jquery.corner.js" type="text/javascript"></script>
<![endif]-->

and also this:

<!--[if !(IE 8)]><!-->
<script src="scripts/jquery.corner.js"></script>
<script>
    // your inline script goes here
</script>
<!--<![endif]-->

Option #2 seemed to have worked for the other person who posted this question, but I couldn't figure out what to put in the part that reads "your inline script goes here" to make this disable work.

Any advice is appreciated.

Many thanks!
0
imakepunch
Asked:
imakepunch
  • 2
1 Solution
 
user_nCommented:
The script that makes problems in ie8 and works in all other browsers is placed on the place of  " // your inline script goes here"
0
 
khairilCommented:
Hi,

You might want to have a look on this, http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx
There also example in there.
0
 
imakepunchAuthor Commented:
thanks for the great/quick response.

user_n: i think i'm following you, but not sure that i'm implementing it correctly (since i tried it and  i still have the problem). the external script that is giving me the issue is called "jquery.corner.js". this is the script i want to disable in IE8, so i have targeted that in the first part. .

the script that i wrote which activates that is not inline in my HTML...i have in a separate external file i created called "script.js" which i linked in my HTML source code. i believe that is what i am supposed to enter in the "//your inline script goes here"?

i copied and pasted that script code and this is what it looks like in my HTML source code (but still having the issue in IE8):


<!--[if !(gte IE 8)]><!-->
    <script src="scripts/jquery.corner.js"></script>
    <script>
            $(document).ready(function(){            
                  $('li.gkplusjm').corner("right");
                  $('li.engagement-ring').corner("right");
                  $('li.proposal').corner("right");
                  $('li.ceremony').corner("right");
                  $('li.accommodations').corner("right");
                  $('li.music').corner("right");
                  $('li.travel').corner("right");      
                  $('li.cabo').corner("right");
                  $('li.registry').corner("right");
                  $('li.reception').corner("right");
                  $('li.blog').corner("right");
                  $('a').corner("right");
                  $('#page-content').corner("25px");
                  $('#footer').corner("top 25px");
            });    
      </script>
<!--<![endif]-->
0
 
imakepunchAuthor Commented:
oh wait...nevermind. i was able to fix it with both of your responses...THANK YOU!

i didn't realize that the conditional statement i was using was for all browsers EXCEPT IE8...so i was pasting my script in there, but still had it activated outside of the conditional statement. i simply deleted it from the original code, and placed the following:

<!--[if !IE 8]><!-->
            <script src="scripts/jquery.corner.js" type="text/javascript"></script>
<!--<![endif]-->

that took care of it!

thanks so much to you both! :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now