Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.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代码在FireFox中无法正常工作 ` .... (函数($){ jQuery(窗口).调整大小(函数(){ var width=jQuery(“#换页”).css('margin-left'); jQuery('#left link').css({width:width}); jQuery('#right link').css({width:width}); }); var width=jQuery(“#换页”).css('margin-left'); jQuery('#left link').css({width:width}); jQuery('#right link').css({width:width}); })(jQuery);_Javascript_Jquery_Firefox_Background Image - Fatal编程技术网

Javascript代码在FireFox中无法正常工作 ` .... (函数($){ jQuery(窗口).调整大小(函数(){ var width=jQuery(“#换页”).css('margin-left'); jQuery('#left link').css({width:width}); jQuery('#right link').css({width:width}); }); var width=jQuery(“#换页”).css('margin-left'); jQuery('#left link').css({width:width}); jQuery('#right link').css({width:width}); })(jQuery);

Javascript代码在FireFox中无法正常工作 ` .... (函数($){ jQuery(窗口).调整大小(函数(){ var width=jQuery(“#换页”).css('margin-left'); jQuery('#left link').css({width:width}); jQuery('#right link').css({width:width}); }); var width=jQuery(“#换页”).css('margin-left'); jQuery('#left link').css({width:width}); jQuery('#right link').css({width:width}); })(jQuery);,javascript,jquery,firefox,background-image,Javascript,Jquery,Firefox,Background Image,我创建了这个脚本,但没有在Firefox中玩,我找不到bug。Chrome和IE播放正确。那么什么是不起作用的 是不是应该在resize上执行的代码?在firebug中使用断点进行测试,或者只是在控制台上打印一些东西。顺便说一句,你可以这样写,让它看起来更好 <body> <a href="link" id="left-link" style="position: fixed; width:0px; height: 100%; "></a>`

我创建了这个脚本,但没有在Firefox中玩,我找不到bug。Chrome和IE播放正确。

那么什么是不起作用的

是不是应该在resize上执行的代码?在firebug中使用断点进行测试,或者只是在控制台上打印一些东西。顺便说一句,你可以这样写,让它看起来更好

<body>
    <a href="link" id="left-link" style="position: fixed; width:0px; height: 100%; "></a>`
    <a href="link" id="right-link" style="position: fixed; width: 0px; right: 0px; height: 100%; "></a>
    <div id="page-wrap"> .... </div>

    <script>
        (function ($) {
            jQuery(window).resize(function () {
                var width = jQuery('#page-wrap').css('margin-left');
                jQuery('#left-link').css({ width: width });
                jQuery('#right-link').css({ width: width });
            });

            var width = jQuery('#page-wrap').css('margin-left');
            jQuery('#left-link').css({ width: width });
            jQuery('#right-link').css({ width: width });

        })(jQuery);
    </script>
</body>

或者它无法调整您试图操纵的两个元素的宽度?在这种情况下,您应该仔细查看宽度变量的值,也许它是在firefox中计算出来的。

注意:
(函数($){…})(jQuery)
的要点是,您可以在
{…}/code>中使用
$
代替
jQuery
?当您进行初始赋值时,DOM是否还没有准备好?你在
宽度
中得到了什么值?在chrome和ie宽度下,根据页面宽度从0px变为其他数字。在firefox中,宽度不要改变!您知道在您的代码中使用了
左边距
?我不明白为什么左边的边距会改变?我在Chrome、Firefox和IE中尝试了fiddle sra。我还将它放在本地计算机上,以排除fiddle上的iframe。左侧的
边距始终为0px。它在所有浏览器中看起来都一样。在chrome和ie上,宽度根据页面宽度从0px更改为其他数字。在firefox中,宽度不变,我找不到bug
$(window).on("resize", function() { /* your stuff here */ });