Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Drupal消息框中,为什么关闭按钮在Chrome中不起作用?_Javascript_Drupal 6 - Fatal编程技术网

Javascript 在Drupal消息框中,为什么关闭按钮在Chrome中不起作用?

Javascript 在Drupal消息框中,为什么关闭按钮在Chrome中不起作用?,javascript,drupal-6,Javascript,Drupal 6,这只发生在Chrome中。IE和Firefox工作得很好。在控制台中,我得到一个错误:uncaughttypeerror:object不是函数 它说错误在这里,但我甚至不知道这在哪里: (function() {with (this[2]) {with (this[1]) {with (this[0]) {return function(event) {onclose() };}}}}) 您与该函数名存在某种冲突 尝试: 或者更好: document.getElementById("aerr

这只发生在Chrome中。IE和Firefox工作得很好。在控制台中,我得到一个错误:
uncaughttypeerror:object不是函数

它说错误在这里,但我甚至不知道这在哪里:

(function() {with (this[2]) {with (this[1]) {with (this[0]) {return function(event) {onclose()
};}}}})

您与该函数名存在某种冲突

尝试:

或者更好:

document.getElementById("aerror").addEventListener('click', function() {
    alert('Hello world');
}, false);

您应该始终使用事件侦听器:

您的js中是否有
onclose()
函数?是的,onclose函数存在,在第一行插入了一些javascript(请参见问题中的代码),但我不知道它来自何处。这是由于冲突,因此您最好使用
window.onclose()
取而代之!window.onclose()工作正常。谢谢我再过21个小时也不能给赏金了,所以我会尽我所能的。
document.getElementById("aerror").addEventListener('click', function() {
    alert('Hello world');
}, false);