Solved

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

Posted on 2011-09-23
4
311 Views
Last Modified: 2012-05-12
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
Comment
Question by:imakepunch
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
user_n earned 500 total points
ID: 36591295
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
 
LVL 13

Expert Comment

by:khairil
ID: 36591308
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
 

Author Comment

by:imakepunch
ID: 36592736
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
 

Author Comment

by:imakepunch
ID: 36592752
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FIx alignment of two texts 1 26
CSS Question 9 42
html form to write data to csv 24 96
Could you point a way to form a view's combo based on Codeigniter's results? 4 18
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now