不工作“点击"在 Firefox、Chrome 和 safari 上 [英] not working "onclick " on firefox, chrome and safari

查看:80
本文介绍了不工作“点击"在 Firefox、Chrome 和 safari 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 python、HTML 和 javascript 的程序.我有两个图像用作按钮更改 onmouseover 和 onmouseout 的颜色.它还有一个在 onclick 事件发生时起作用的函数.一切都在 Internet Explorer 上运行良好(这是 extrange),但 onclick 事件在 safari、chrome 或 firefox 上不起作用.错误控制台不标记任何错误,控制台上的 error.log 也不标记.

I am working on a program using python, HTML and javascript. I have two images that works as a button changin colors onmouseover and onmouseout. It also has a function that works when the onclick event happens. Everything is working very well on Internet Explorer (which is extrange) but the onclick event is not working on safari,chrome or firefox. The error console doesnt mark any error, neither the error.log on console.

你看到代码有什么问题吗?是否有一些功能如 onmouseover 或 onmouseout 或 onclick 在这些浏览器上不起作用?

Do you see anything wrong with the code? Are there some functions like onmouseover or onmouseout or onclick that does not work on those browsers?

      <td><img src="/RH/images/tacha.png" onclick="eliminarRenglon('eliminar','%s');testing()" 
      onmouseover="this.src='/RH/images/tacha_2.png'" onmouseout="this.src='/RH/images/tacha.png'" /></td>''' % variable

     function testing(){
        alert("JUST TESTING");
     }

甚至测试"功能都不起作用.eliminarRenglon"功能在 IE 上运行良好,测试"功能也是如此.这是eliminarRenglon"的代码,但由于它在 IE 上运行良好,我不知道是不是它的问题.

not even the "testing" function works. The "eliminarRenglon" function works very well on IE, and also the "testing" function. Here is the code of the "eliminarRenglon", but as it works very well on IE i dont know if the problem is with it.

function eliminarRenglon(tipo,id) { 
   var nivel = "No"
   var divPrincipal = document.getElementById("divPrincipal");
   var idReq = document.getElementById("req" + id).value;
   var claveProyecto = document.getElementById("claveproyecto").value;
   var url = 'actualizarRenglonAjax.py?nivel='+nivel+'&tipo='+tipo+'&idReq='+idReq+'&claveProyecto='+claveProyecto;
   if(document.getElementById("selectReq" + id).value == ""){           
       xmlhttp = GetXmlHttpObject(nivel);
       if(!xmlhttp) {
             alert("Browser does not support HTTP Request");
             return;
       }
       var xml = xmlhttp;
       xmlhttp.onreadystatechange = function() {
           if(xml.readyState == 1) {
               loading.innerHTML = "<img src='/RH/images/loading_4.gif' />"
           }
           if(xml.readyState == 4) {
            divPrincipal.innerHTML = xml.responseText;
            actualizarTodo();
           }
       };
       xmlhttp.open("GET",url,true);
       xmlhttp.send(null);
       return true;
   }
   else
       alert("No se puede eliminar");
}

我非常感谢您的帮助非常感谢!

I would really appreciate the help Thanks a lot!

推荐答案

我建议为图像添加一个选择器值,然后以不显眼的方式绑定事件(使以后的维护更容易一些).

I'd suggest adding a selector value to the image, then binding events the unobtrusive way (makes maintenance a bit easier later on).

这样做:

<img src="/RH/images/tacha.png" class="myImage" />

然后,在加载 DOM 后,附加您的事件(为简单起见,这里是 jquery)

then, after the DOM is loaded, attach your events (jquery here for simplicity)

$('img.myImage').bind('click', function() { 
  alert('testing!'); 
  eliminarRenglon('eliminar','%s'); 
});

这篇关于不工作“点击"在 Firefox、Chrome 和 safari 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆