Why does this fail in Firefox and Chrome?
This is a common piece of JavaScript used to show a customer splash screen in Silverlight:
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;
}
For some reason, Firefox and Chrome get errors on this line:
var rectBar = myHost.content.findName("rectBar");
They complain that "myHost is null".
This works fine in Internet Explorer, but in Firefox and Chrome the progress bar is never updated because of this error.
The key portion it is traversing looks like this:
<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>
Because it's xaml1
, not Xaml1
, and Internet Explorer is too lazy to care about your typo.
because the other browsers are case-sensitive. "Xaml1" != "xaml1"
精彩评论