代码:
$(document).ready(function() {
$("#main_div").bind('click', function(e){
var x = event.pageX-document.getElementById("main_div").scrollLeft;
var y = event.pageY-document.getElementById("main_div").scrollTop;
document.pointform.form_x.value = x;
document.pointform.form_y.value = y;
var a= x-404;
var b= y-88;
if(document.getElementById('optionselect').value=='a')
{
$("#container-5").css({"top":b,"left":a});
$("#container-5").show();
e.stopPropagation();
}
else if(...)
{
...
}
});
});
Hey Guys,代码在IE和Chrome中运行良好,但是当我尝试在firefox中运行相同时,它会抛出错误“未定义事件”并将光标指向定义var x的位置。我该如何克服这个问题?
答案 0 :(得分:1)
更改
$("#main_div").bind('click', function(e){
要
$("#main_div").bind('click', function(event){
一切都应该没问题。)
答案 1 :(得分:0)
尝试
$("#main_div").bind('click', function(event){ // Cause you seem to use
// event argument and not e
而不是
$("#main_div").bind('click', function(e){
Also Change e.stopPropagation()
;
到
event.stopPropagation();