JQuery $(window).width()和$(window).height()仅在网站的某些部分返回NULL

时间:2012-02-07 09:50:14

标签: jquery

当用户在表单字段中单击时,我已经集成了jquery代码来简单地调暗弹出窗口

这在我们的首页上工作正常,但在论坛页面(phpbb2派生)上,我在firebug控制台中收到如下错误: -

$(“#fuzz”)为空 [打破此错误]

$(“#fuzz”)。css(“height”,$(document).height());

我们的代码如下: -

<script type="text/javascript"> 
jQuery(document).ready(function(){  

   //Adjust height of overlay to fill screen when page loads  

   $("#fuzz").css("height", $(document).height());  

   $('#clickme').focus( function() {
       $("#fuzz").fadeIn();  
      return false;         
  });      

   //When the link that triggers the message is clicked fade in overlay/msgbox  
   $(".alert").click(function(){  
      $("#fuzz").fadeIn();  
      return false;  
   });  

   //When the message box is closed, fade out  
   $(".close").click(function(){  
      $("#fuzz").fadeOut();  
      return false;  
   });  

});  

//Adjust height of overlay to fill screen when browser gets resized  
$(window).bind("resize", function(){  
   $("#fuzz").css("height", $(window).height());  
});
</script> 

网站为http://www.motorhomefacts.com

遗憾的是,搜索框仅显示给网站的成员,但无论论坛内的任何页面如何,该错误都存在于firebug中。

http://www.motorhomefacts.com/forums.html

我们在Firebug中显示了一些其他错误,但我不是一个java编码器(php ok)所以任何帮助都会非常感激,即

Overlib错误 缺少)正式参数后 function escSglQuote(st overlib.js(第118行,第23栏)

2 个答案:

答案 0 :(得分:0)

您已在jQuery代码中的某处设置了noConflict。 jQuery已设置为使用jQuery(),而不是$()

更改您的代码,将$的实例替换为jQuery,它会起作用,例如:

jQuery("#fuzz").css("height", jQuery(document).height()); 

答案 1 :(得分:0)

overlib.js文件似乎在这一行被截断:

function escSglQuote(st

文件传输有问题吗?也许你的服务器空间不足?