锚标记中的Onclick事件在IE10中不起作用 [英] Onclick event in anchor tag not working in IE10

查看:452
本文介绍了锚标记中的Onclick事件在IE10中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Asp.Net用户控件中有一个定位点.我已经将一些代码连接到onclick事件.由于Internet Explorer 10中的某些原因,该事件未触发.标记的结构为

I've an anchor in an Asp.Net user control. I've wired some code to the onclick event. For some reason in Internet Explorer 10, the event is not firing. The markup is structured as

<a href="#" id="myAnchor" onclick="myFunction();return false;"></a> 

其中myFunction是一个简单的JavaScript函数.对于那些想要查看实际页面的人,这里是链接:

where myFunction is a simple JavaScript function. For those who want to see the page in action, here is the link:

http://alt.thedominion.ca/TheBrokerAdvantage/LocateABroker.aspx

任何帮助将不胜感激!

推荐答案

问题出在服务器端代码,而不是浏览器或JavaScript.

The problem is with your server side code, not the browser or JavaScript.

如果您在IE10中检查JavaScript控制台,则在单击链接时会看到以下错误:

If you check the JavaScript console in IE10 you will see the following error when clicking the link:

SCRIPT5009:"ValidatorValidate"未定义

SCRIPT5009: 'ValidatorValidate' is undefined

哪个指向函数的第二行:

Which points to the second line in the function:

function doSearch() {
    var regExValidate = document.getElementById("ctl00_BrokerSearchMiddle_ctl00_ValidPostalCode");
    ValidatorValidate(regExValidate);

    var postalCode = $find("ctl00_BrokerSearchMiddle_ctl00_PostalCode").get_value();

    if (regExValidate.isvalid && postalCode.indexOf("e.g") == -1) {
        document.location.href = "?postalCode=" + postalCode;
    }
}

这意味着onclick正常工作,您只是遇到了JS错误.

This means the onclick is working just fine, you simply have JS error.

现在的问题是,为什么ValidatorValidate在其他浏览器(甚至是IE9)中也存在,但在IE10中却不存在.好吧,在IE10中作为浏览器输出的一部分.

Now the question is why ValidatorValidate exists in other browsers (even IE9) but not in IE10. Well, in IE10 the script where it's being defined is not included, meaning the server never put the line <script src="..."> with that URL as part of the output to the browser.

我只能猜测服务器端代码正在检查浏览器版本,并且据此包括某些脚本.检查该代码,并摆脱掉那些绝不是好主意的东西.

I can only guess that the server side code is checking the browser version and according to that include certain scripts. Check that code and get rid of such things as it's never a good idea.

经过一番研究,我发现发生了什么事.您正在使用Sitefinity 3.7版来构建您的网站(根据您的问题)并以官方方式

After some research I found what's going on. You are using Sitefinity version 3.7 to build your site (according to this question of yours) and as officially stated here:

我想通知您,很遗憾,Sitefinity 3.7不支持Internet Explorer 10,并且您的Sitefinity 3.7可能不适用于此浏览器版本.不便之处,敬请谅解

I want to inform you that unfortunately Sitefinity 3.7 does not support Internet Explorer 10 and your Sitefinity 3.7 might not work properly with this browser version. Apologies for the inconvenience

如果要支持IE10,则必须升级Sitefinity.

You will have to upgrade your Sitefinity if you want IE10 support.

这篇关于锚标记中的Onclick事件在IE10中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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