IE6 textBox.focus();导致“意外调用方法或财产访问” [英] IE6 textBox.focus(); causing "Unexpected call to method or property access"
问题描述
我得到JS错误Unexpected call to方法或属性访问在IE6中间歇性地在线 oAutoCompleteTextBox.focus();。希望以前有人看到过这个问题,可以提供一些关于如何解决这个问题的见解。以下是使用的上下文。 (b)
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ '<%= this.AutoCompleteTextBox.ClientID%>');
...
SetupDefaultValues();
}
函数SetupDefaultValues(){
...
if(canFocus(oAutoCompleteTextBox)){
oAutoCompleteTextBox.focus();
}
}
我的第一篇文章在stackoverflow上 - YAY!
OK,所以问题是jQuery $(document).ready()事件在updatepanel异步回发中没有被触发,解决方案是将ready()中的函数定义重构为显式函数定义(函数pageReady(){...} ),并将新的pageReady()事件处理程序添加到ASP.net Sys.WebForms.PageRequestManager endRequest 事件,该事件仅在异步回发时触发。所以现在的代码如下所示:
Sys.WebForms.PageRequestManager.getInstance()add_endRequest(pageReady);
$(document).ready(pageReady);
函数pageReady(){
...
oAutoCompleteTextBox = GetElement('<%= this.AutoCompleteTextBox.ClientID%>');
...
SetupDefaultValues();
函数SetupDefaultValues(){
...
if(canFocus(oAutoCompleteTextBox)){
oAutoCompleteTextBox.focus();
$ b感谢大家的帮助和关注 - 花了一段时间弄清楚,我很高兴它解决了:)
The issue is now resovled :) Thanks for everyone's help and attention!
I'm getting the JS error "Unexpected call to method or property access" in IE6 intermittently on the line "oAutoCompleteTextBox.focus();". Hopefully, someone has seen this issue before and can provide some insight on how to solve it. Below is the context of the usage.
$(document).ready(function () {
...
oAutoCompleteTextBox = GetElement('<%=this.AutoCompleteTextBox.ClientID%>');
...
SetupDefaultValues();
}
function SetupDefaultValues() {
...
if(canFocus(oAutoCompleteTextBox)) {
oAutoCompleteTextBox.focus();
}
}
My 1st post on stackoverflow - YAY!
解决方案 OK, so the issue was that the jQuery $(document).ready() event isn't fired on updatepanel async postbacks. The solution is to refactor the function definition inside the ready() into an explicit function definition (i.e. function pageReady(){...}) and add the new pageReady() eventhandler to ASP.net Sys.WebForms.PageRequestManager endRequest event which is only fired on async postbacks.
So the code now looks like this:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageReady);
$(document).ready(pageReady);
function pageReady() {
...
oAutoCompleteTextBox = GetElement('<%=this.AutoCompleteTextBox.ClientID%>');
...
SetupDefaultValues();
}
function SetupDefaultValues() {
...
if(canFocus(oAutoCompleteTextBox)) {
oAutoCompleteTextBox.focus();
}
}
Thanks for everyone's help and attention - took a while to figure out, I'm just glad it's resolved :)
这篇关于IE6 textBox.focus();导致“意外调用方法或财产访问”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!