Windows7 中的 IE8 和 IE9 问题:加载后无法调用函数()
Issue with IE8 and IE9 in Windows7: Does not work to call function after load()
<script type="text/javascript" src="https://domain/functionfile.js"></script>
<script type="text/javascript">
var jQ110 = $.noConflict(true);
jQ110(function ($) {
if ($( "#element20-input" ).length>0) {
$( "#element20-input" ).load(
"https://domain/page #elementwidget-input", function() {
widgetfrontend(248);
});
}
});
</script>
html
<div id="element20-input">Loading...</div>
<div id="elementwidget-result">Loading...</div>
以上在 Safari、Opera、Firefox、Chrome 等和 IE9+ 中工作正常,但在 IE8 中无效。控制台在行中抛出“Object expected
”(使用 IE8 时):
widgetfrontend(248);
widgetfrontend
函数在 https://domain/functionfile.js
中定义如下:
function widgetfrontend( mun_id ) {
alert( mun_id );
}
为什么报错? javascript 加载不正确还是什么?这是为什么?
更新
正在使用
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
我正在使用跨域脚本。是的,在服务器上设置了允许访问来源等,这样就可以了。
如果有人偶然发现了这个问题。 IE8 和 IE9 使用 XDomainRequest(Microsoft 自己处理 ajax 调用中的响应)。使用 SSL 时,XDomainRequest 仅在两个域都具有 SSL 时才有效。
<script type="text/javascript" src="https://domain/functionfile.js"></script>
<script type="text/javascript">
var jQ110 = $.noConflict(true);
jQ110(function ($) {
if ($( "#element20-input" ).length>0) {
$( "#element20-input" ).load(
"https://domain/page #elementwidget-input", function() {
widgetfrontend(248);
});
}
});
</script>
html
<div id="element20-input">Loading...</div>
<div id="elementwidget-result">Loading...</div>
以上在 Safari、Opera、Firefox、Chrome 等和 IE9+ 中工作正常,但在 IE8 中无效。控制台在行中抛出“Object expected
”(使用 IE8 时):
widgetfrontend(248);
widgetfrontend
函数在 https://domain/functionfile.js
中定义如下:
function widgetfrontend( mun_id ) {
alert( mun_id );
}
为什么报错? javascript 加载不正确还是什么?这是为什么?
更新
正在使用
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
我正在使用跨域脚本。是的,在服务器上设置了允许访问来源等,这样就可以了。
如果有人偶然发现了这个问题。 IE8 和 IE9 使用 XDomainRequest(Microsoft 自己处理 ajax 调用中的响应)。使用 SSL 时,XDomainRequest 仅在两个域都具有 SSL 时才有效。