未在Firefox中执行PageMethod的返回函数

Return function of a PageMethod not executing in Firefox

本文关键字:返回 函数 PageMethod 执行 Firefox 未在      更新时间:2023-09-26

我在Firefox中使用JS函数时遇到了一个小问题。预期的结果(在IE和Chrome中相应地起作用)是执行服务器端代码,并在LoadDetails函数中返回一个数组。

function ShowEvent(index) {
    PageMethods.LoadDetailsEvent(index, LoadDetails);
}
function LoadDetails(val) {
    document.getElementById('lblName').innerText = val[0];
    document.getElementById('lblDate').innerText = val[1];
    document.getElementById('lblTime').innerText = val[2];
    document.getElementById('lblPlace').innerText = val[3];
    document.getElementById('lblDescription').innerText = val[4];
    $find('mpeShowEvent').show();
}

在其他浏览器中,数据被正确加载到标签中,但在Chrome中,它们显示为默认值。

我在这里错过了什么?

innerText是Internet Explorer首次引入的非标准属性。标准属性是textContent,但至少需要IE9。或者,您可以使用一个跨浏览器JavaScript库来处理差异。另一种方法是直接更改子文本节点的数据。

Firefox使用W3C兼容的textContent属性。这就是你的问题所在。