[英]Script is not working in IE Browser
I am using click event function to save the every activity of the user in the database, but the script is not working in IE browser. 我正在使用click event函数将用户的每项活动保存在数据库中,但是该脚本在IE浏览器中不起作用。 Please suggest me to fix this issue.
请建议我解决此问题。
document.addEventListener("click", function(event){
var url_path = window.location.pathname;
var type = event.target.type
var name = event.target.name
var old_value = event.target.value
if(name === undefined || name == null || name.length <= 0)
{
}
else
{
$.ajax({type: "POST",
url: "application/record_user_activity",
data: { click_obj_type:type, click_obj_name:name,click_obj_old_value: old_value},
success:function(result){
// alert("success")
}});
}
});
for IE, use attachEvent
instead of addEventListener
because addEventListener
is not supported in IE < 9. 对于IE,请使用
attachEvent
而不是addEventListener
因为IE <9中不支持addEventListener
。
Also note that From IE > 11, attachEvent
is not supported 另请注意,从IE> 11开始,不支持
attachEvent
So, try to use 因此,尝试使用
if(window.addEventListener){
//code
}
else if(window.attachEvent){
// code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.