简体   繁体   中英

Can't target Internet Explorer

I am trying to make it so that if the browser is Internet Explorer I want to show an iframe, but it isn't working, If I use IE it doesn't show and I can't figure out why.

Below is my code:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Fastlane Autosales</title>
<link href="http://fonts.googleapis.com/css?family=Oswald:400,300" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>


<style>
 body {width:100%; height:100%; overflow:hidden, margin:0}
 html {width:100%; height:100%; overflow:hidden}
  #size {   width: 900px;   
        height: 700px; 
        display: block;}
</style>


 <body>

<!--[if IE]>


<div style="position: absolute; top: 110px; left: 20px;">
<iframe id = "size" frameborder="0" scrolling="yes" marginheight="0" marginwidth="0"      style="background-color:#E6E6E6" src="http://listings2011.boostmotorgroup.com/Search.aspx?    DealershipID=4075&amp;isLogo=0&amp;MediaID=36"></iframe>
</div>

<![endif]-->

</body>
</html>

Browser detection is brittle and problematic at best. A cleaner approach would be to do feature detection (test for things you need and enable (or disable) features based on those features. Modernizer is a great way to do this.

According to Microsoft , "As of Internet Explorer 10, conditional comments are no longer supported by standards mode".

I verified this by testing your code in IE. When I switched to browser modes 7-9, I was able to see the iframe, but not in IE 10 mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM