无法获取下拉菜单以在Internet Explorer中显示

时间:2013-06-13 21:36:08

标签: html css internet-explorer doctype html-components

我使用预先构建的CSS和HTML在我的网站上显示下拉菜单,但菜单在Internet Explorer中不起作用。我不确定它是doctype还是什么,我把它链接到csshover.htc页面,因为它附带,但它仍然无法工作。我将在下面的代码中列出包含doctype和file链接的菜单的第一部分,以及csshover.htc代码。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  

<link rel="stylesheet" href="menu.css" type="text/css" media="screen" />  

<title>Mega Drop Down Menu</title>  
<!--[if IE 6]>  
<style>  
body {behavior: url("csshover.htc");}  
#menu li .drop {background:url("img/drop.gif") no-repeat right 8px;   
</style>  
<![endif]-->  

<body>

<ul id="menu">

 <li><a href="#" class="drop">Home</a><!-- Begin Home Item -->

    <div class="dropdown_2columns"><!-- Begin 2 columns container -->

        <div class="col_2">
            <h2>Welcome !</h2>
        </div>

        <div class="col_2">
            <p></p>             

        </div>



    </div><!-- End 2 columns container -->

以下是csshover.htc文件中的信息:

<public:attach event="ondocumentready" onevent="CSSHover()" />
<script>

window.CSSHover=(function(){var m=/(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):            (hover|active|focus))/i;var n=/(.*?)\:(hover|active|focus)/i;var o=/[^:]+:([a-z\-    ]+).*/i;var p=/(\.([a-z0-9_\-]+):[a-z]+)|(:[a-z]+)/gi;var q=/\.([a-z0-9_\-]*on(hover|active|focus))/i;var s=/msie (5|6|7)/i;var t=/backcompat/i;var u={index:0,list:['text-kashida','text-kashida-space','text-justify'],get:function(){return this.list[(this.index++)%this.list.length]}};var v=function(c){return c.replace(/-(.)/mg,function(a,b){return b.toUpperCase()})};var w={elements:[],callbacks:{},init:function(){if(!s.test(navigator.userAgent)&&!t.test(window.document.compatMode)){return}var a=window.document.styleSheets,l=a.length;for(var i=0;i<l;i++){this.parseStylesheet(a[i])}},parseStylesheet:function(a){if(a.imports){try{var b=a.imports;var l=b.length;for(var i=0;i<l;i++){this.parseStylesheet(a.imports[i])}}catch(securityException){}}try{var c=a.rules;var r=c.length;for(var j=0;j<r;j++){this.parseCSSRule(c[j],a)}}catch(someException){}},parseCSSRule:function(a,b){var c=a.selectorText;if(m.test(c)){var d=a.style.cssText;var e=n.exec(c)[1];var f=c.replace(o,'on$1');var g=c.replace(p,'.$2'+f);var h=q.exec(g)[1];var i=e+h;if(!this.callbacks[i]){var j=u.get();var k=v(j);b.addRule(e,j+':expression(CSSHover(this, "'+f+'", "'+h+'", "'+k+'"))');this.callbacks[i]=true}b.addRule(g,d)}},patch:function(a,b,c,d){try{var f=a.parentNode.currentStyle[d];a.style[d]=f}catch(e){a.runtimeStyle[d]=''}if(!a.csshover){a.csshover=[]}if(!a.csshover[c]){a.csshover[c]=true;var g=new CSSHoverElement(a,b,c);this.elements.push(g)}return b},unload:function(){try{var l=this.elements.length;for(var i=0;i<l;i++){this.elements[i].unload()}this.elements=[];this.callbacks={}}catch(e){}}};var x={onhover:{activator:'onmouseenter',deactivator:'onmouseleave'},onactive:{activator:'onmousedown',deactivator:'onmouseup'},onfocus:{activator:'onfocus',deactivator:'onblur'}};function CSSHoverElement(a,b,c){this.node=a;this.type=b;var d=new RegExp('(^|\\s)'+c+'(\\s|$)','g');this.activator=function(){a.className+=' '+c};this.deactivator=function(){a.className=a.className.replace(d,' ')};a.attachEvent(x[b].activator,this.activator);a.attachEvent(x[b].deactivator,this.deactivator)}CSSHoverElement.prototype={unload:function(){this.node.detachEvent(x[this.type].activator,this.activator);this.node.detachEvent(x[this.type].deactivator,this.deactivator);this.activator=null;this.deactivator=null;this.node=null;this.type=null}};window.attachEvent('onbeforeunload',function(){w.unload()});return function(a,b,c,d){if(a){return w.patch(a,b,c,d)}else{w.init()}}})();

1 个答案:

答案 0 :(得分:0)

转换为<!DOCTYPE HTML>

并添加 <meta http-equiv="X-UA-Compatible" content="IE=Edge" />

进入你的脑海 还会添加<html>代码和</head>代码 例如

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title></title>
</head>
<body>
<!-- Content -->
</body>
</html>

您遗漏了许多必要的标签,并确保您的问题得到解决

您也没有关闭<ul>代码和<li>代码