Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE8问题-jQuery在调整页面大小时调整导航html_Javascript_Jquery_Html_Css_Internet Explorer 8 - Fatal编程技术网

Javascript IE8问题-jQuery在调整页面大小时调整导航html

Javascript IE8问题-jQuery在调整页面大小时调整导航html,javascript,jquery,html,css,internet-explorer-8,Javascript,Jquery,Html,Css,Internet Explorer 8,使用下面的代码,我不希望IE8拾取响应导航。调整窗口大小时,IE8将删除导航。我的学生有一个针对IE8的lt-ie9等级。您能告诉我如何调整代码,以便如果浏览器大小低于767,它将使用桌面版本 function resizeNav() { if (!nav) { nav = {}; nav.root = jQuery('#navigation'); nav.primary = nav.root.find('.menu'); nav.

使用下面的代码,我不希望IE8拾取响应导航。调整窗口大小时,IE8将删除导航。我的学生有一个针对IE8的lt-ie9等级。您能告诉我如何调整代码,以便如果浏览器大小低于767,它将使用桌面版本

function resizeNav() {
if (!nav) {
        nav = {};
        nav.root = jQuery('#navigation');
        nav.primary = nav.root.find('.menu');
        nav.secondary = jQuery('.secondary-links');
        nav.moveable = nav.secondary.children('li');
        nav.icon = jQuery('<div id="menu-icon" class="btn">Navigation</div>');

        nav.icon.click(function () {
            nav.primary.slideToggle('slow');
            nav.icon.toggleClass('active');
        });
    }

    // Position everything
    if (getWidth() <= 767) {
        nav.moveable.appendTo(nav.primary);
        nav.root.prepend(nav.icon);
        nav.primary.hide();
    } else {
        nav.moveable.appendTo(nav.secondary);
        nav.icon.detach();
        nav.primary.show();
    }

    nav.icon.removeClass('active');
}

如果你只想影响IE8,为什么要使用JS?仅仅使用一个只有IE8的CSS文件不是更好吗。这将保持你的代码干净和黑客免费

<!--[if lte IE 8]>
    <link rel="stylesheet" type="text/css" href="ie8-and-down.css" />
<![endif]-->
假设您的lt-ie9类添加了html元素,最简单的方法就是检查它以及宽度:

if (!html.lt-ie9 && getWidth() <= 767) {
然后将上述内容修改为:

if (!isLtIe9 && getWidth() <= 767) {

完美的谢谢你的帮助。
if (!isLtIe9 && getWidth() <= 767) {