64.1 F
Los Angeles
Friday, April 26, 2024

Trump Lawyer Resigns One Day Before Trial To Begin

Joseph Tacopina has filed with the courts that he will not represent Donald J. Trump. The E. Jean Carroll civil case is schedule to begin Tuesday January 16,...

Judge Lewis A. Kaplan Issues Order RE Postponement

On May 9, 2023, a jury found Donald J. Trump liable for sexual assault and defamation. The jury awarded Ms. Carroll $5 million in damages. Seven months ago,...

ASUS Announces 2023 Vivobook Classic Series

On April 7, 2023, ASUS introduced five new models in the 2023 Vivobook Classic series of laptops. The top laptops in the series use the 13th Gen Intel® Core™...
StaffIncremental BloggerSilverlight JavaScript error in Firefox

Silverlight JavaScript error in Firefox

I’ve been tinkering with a tiny Silverlight app, and I kept running into the situation where the code would work in IE and Safari, but not Firefox. Turns out I was using some older sample code as a guide that had a problem.

In particular, when creating the silverlight object, I was using code like this:

<div id=”agControlHost”>
  <script type=”text/javascript”>
    Sys.Silverlight.createObjectEx({source:’page.xaml’,
    parentElement: agControlHost,
    id:’silverlightObj’,
    properties: { width:’300′,
    height:’200′,
    background:’#ffffffff’,
    isWindowless: ‘false’,
    framerate:’24’,
    version:’0.8′ },
    events: { onError:null,
    onLoad:null },
    context:null });
  </script>
</div>

Unfortunately, I kept getting an error that the parentElement agControlHost didn’t exist. It took me awhile to realize that I needed to use getElementById() instead of using the element’s name by itself to fix the problem. Here’s the correct way to create a silverlight object:

<div id=”agControlHost”>
  <script type=”text/javascript”>
    Sys.Silverlight.createObjectEx({source:’page.xaml’,
    parentElement: document.getElementById(‘agControlHost’),
    id:’silverlightObj’,
    properties: { width:’300′,
    height:’200′,
    background:’#ffffffff’,
    isWindowless: ‘false’,
    framerate:’24’,
    version:’0.8′ },
    events: { onError:null,
    onLoad:null },
    context:null });
  </script>
</div>

Now my Silverlight experiment works just fine in IE, Firefox, and Safari.

Loren
Lorenhttp://www.lorenheiny.com
Loren Heiny (1961 - 2010) was a software developer and author of several computer language textbooks. He graduated from Arizona State University in computer science. His first love was robotics.

Latest news

Related news