Firefox와 Chrome에서이 작업이 실패하는 이유는 무엇입니까?
이것은 Silverlight에서 고객 스플래시 화면을 표시하는 데 사용되는 일반적인 JavaScript입니다.function onSourceDownloadProgressChanged(sender, eventArgs) {
var myHost = document.getElementById("Xaml1");
var rectBar = myHost.content.findName("rectBar");
var rectBorder = myHost.content.findName("rectBorder");
if (eventArgs.progress)
rectBar.Width = eventArgs.progress * rectBorder.Width;
else
rectBar.Width = eventArgs.get_progress() * rectBorder.Width;
}
다음과 같은 이유로 Firefox 및 Chrome에서 다음과 같은 오류가 발생합니다.
var rectBar = myHost.content.findName("rectBar");
" myHost는 null "입니다.
Internet Explorer에서는 정상적으로 작동하지만 Firefox 및 Chrome에서는이 오류로 인해 진행률 막대가 업데이트되지 않습니다.
이동하는 주요 부분은 다음과 같습니다.
<div id="silverlightControlHost">
<object id="xaml1" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/MyApp.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="autoUpgrade" value="true" />
<param name="splashscreensource" value="ClientBin/SplashScreen.xaml" />
<param name="onSourceDownloadProgressChanged" value="onSourceDownloadProgressChanged" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
잘 잡습니다. 나는 그것을 선택하지 않은 것에 놀랐다. –
@ NissanFan : 나중에 참조 할 수 있도록, 이와 같은 간단한 할당으로 인한 오류는 거의 항상 이와 같은 오타를 나타냅니다. :) –