Solved

Don't read in IE

Posted on 2008-10-23
3
152 Views
Last Modified: 2010-04-09
I have some javascript code that causes an error in IE.  I know how to add code that is only read in IE, but is there a way have add that is only read if you are NOT in IE?

I tried this but it didn't work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 
	<link href='http://cp.com/' rel='home' title='CP'/>
	<meta content='index,follow' name='robots'/>
	<meta name="keywords" content="ph" />
	<meta name="description" content="This is what will show up in search engine results as the description of the site" />
	<meta name="author" content="CP" />
<!--[if IE]>	
		<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.js" type="text/javascript" charset="utf-8"></script>
	<script src="/assets/scripts/jquerycssmenu.js" type="text/javascript" charset="utf-8"></script>
	<script src="/assets/scripts/init.js" type="text/javascript" charset="utf-8"></script>
	<script src="/assets/scripts/jquery.preload-min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" src="/assets/scripts/jquery.pngFix.js"></script> 
 
	<script type="text/javascript"> 
	    $(document).ready(function(){ 
	        $(document).pngFix(); 
	    }); 
	</script>	
<![endif]-->
 
	<link rel="stylesheet" href="/assets/css/main-styles.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="/assets/css/print-styles.css" type="text/css" media="print" />
	
<!--[if IE]><link rel="stylesheet" href="/assets/css/ie-style.css" media="screen" type="text/css" /><![endif]-->
	
<!--[if IE 6]><link rel="stylesheet" href="/assets/css/ie6-style.css" media="screen" type="text/css" /><![endif]-->
 
	<!-- Analytics -->

Open in new window

0
Comment
Question by:walker6o9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
bluV11t earned 500 total points
ID: 22789227
Hi!
The conditional comment (like <!--[if IE]> ) only applies to IE.

"IE-based browsers like Maxthon and Avant handle them like Internet Explorer does while browsers using other layout engines see them simply as regular comments. Internet Explorer on the Mac uses a different layout engine and doesn't support conditional comments."
http://www.javascriptkit.com/dhtmltutors/csshacks.shtml
http://www.quirksmode.org/css/condcom.html

I think you need to check browser with javascript and output accordingly
http://www.quirksmode.org/js/detect.html
0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22791604
what you do is simply choose the IE conditional test at the beginning, and if it is not IE, you run the rest of the code for all other browsers --

if IE -- do this ...
else .... do this ....

Remember, you will need different code for IE6 than IE7 in many cases.  IE6 is the least compliant, so do --

If IE6 then do this
else if IE7 do that
else do the rest.
0
 
LVL 7

Expert Comment

by:bluV11t
ID: 22794717
The problem with your solution scratcyboy is that other browsers still treats conditional comments as regular comments.

<!--[if !IE]> and <!--[if IE]>  <![else]>  is therefore pointless IMO.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

734 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