Javascript 2个错误:可能的跨浏览器问题

Javascript 2个错误:可能的跨浏览器问题,javascript,jquery,html,Javascript,Jquery,Html,我正在制作一个JavaScript游戏,遇到了两个问题,我将尝试详细描述这两个问题。出现问题的网页是jaminweb.com/Snake.html 首先,我的一个听众似乎没有工作 在我脑海中的脚本标签之间 及 出于某种原因,我认为这些变量在某些浏览器上的计算方式有所不同。这可能是问题所在,我该如何解决呢?不知道这是否有帮助,但如果你有一个带有超链接的按钮,地址将不起作用,因为URL中使用了你的计算机/用户名以及保存在其中的文件名,所以假设你这样做了 <button id="buttonna

我正在制作一个JavaScript游戏,遇到了两个问题,我将尝试详细描述这两个问题。出现问题的网页是jaminweb.com/Snake.html

首先,我的一个听众似乎没有工作

在我脑海中的脚本标签之间


出于某种原因,我认为这些变量在某些浏览器上的计算方式有所不同。这可能是问题所在,我该如何解决呢?

不知道这是否有帮助,但如果你有一个带有超链接的按钮,地址将不起作用,因为URL中使用了你的计算机/用户名以及保存在其中的文件名,所以假设你这样做了

<button id="buttonname"> Start </button>
然后

    $("#buttonname").click(function()
{
  <!-- going to another page here the computer will not be able to find that page because of the user in the link: file:///C:/Users/UserName/Desktop/xxx%20stuff/Corn%20Puff%20Cereal.html
  s = new game(param1, param2, param3);
});

另一件事是s是一个变量,您之前声明过吗?

是否包含jquery库?脚本是否包含在$document.ready中,以确保buttonname已加载到html中。此外,如果有错误,请提供控制台的错误。请听@Adjit,并尝试var height=Math.floorparseInt$somediv.height+1;否则JS可能会尝试连接字符串,而不是添加整数。
var height = Math.floor($("#somediv").height())+1; 
var width =  Math.floor($("#somediv").width())+1;
<button id="buttonname"> Start </button>
    $("#buttonname").click(function()
{
  <!-- going to another page here the computer will not be able to find that page because of the user in the link: file:///C:/Users/UserName/Desktop/xxx%20stuff/Corn%20Puff%20Cereal.html
  s = new game(param1, param2, param3);
});