Firefox说这不是一个功能。必须是一个简单的bug,但我看不到它

时间:2010-07-31 13:00:16

标签: javascript cross-browser

所有其他浏览器都运行得很好,但firefox说'分享不是一个功能'。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

    <script type="text/javascript">
    function share(){
        var url = "http://www.facebook.com/sharer.php?u=http://google.com";
        var win = window.open(url, "share", "status = 1, height = 500, width = 600, resizable = 0" );
        var pollTimer = window.setInterval(function() {
            if (win.closed) {
                window.clearInterval(pollTimer);
                window.location = "http://gmail.com";
            }
        }, 200);

    }
    </script>

</head>

<body>

<div id="sharebox">
    <img id="share" src="img/share.png" onclick="share();" />
</div>

</body>
</html>

2 个答案:

答案 0 :(得分:3)

我发现了问题。不允许使用与函数名称具有相同ID的对象。我从来不知道:s

答案 1 :(得分:1)

如果没有更多信息,这将无法解决,但您可能会发现此函数所在的javascript文件出现错误,因此解析停止,如果该函数位于该部分之后也不会被解析错误。

有些浏览器比其他浏览器更容易出错。

如果您使用JSLint(http://jslint.com/)来修复它报告的错误,它可能会解决您的问题。

否则,请尝试使用firebug extension查看错误的位置。