Firefox says this is not a function. Must be a simple bug, but I can not see it
All the oth开发者_JAVA技巧er browsers operate just fine with this, but firefox says 'share is not a function'.
<!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>
I found the problem. You are not allowed an object with the same id as a function name. I never knew that :s
Without more information this will be impossible to solve, but you may find that the javascript file this function is in had an error, so the parsing stops, then this function also wouldn't be parsed if it is after the part with an error.
Some browsers are more forgiving than others are on errors.
If you use JSLint (http://jslint.com/) to fix the errors that it reports, it may fix your problem.
Otherwise try to use the firebug extension to see where the error may be.
精彩评论