locked
OnSourceDownloadProgressChanged not called RRS feed

  • Question

  • Hey guys,

    I'm trying to create my silverlight object inside a htm-page via javascript (use createObject from Silverlight.js). Everything works fine except one point: the onSourceDownloadProgressChanged-event is not fired so that my splashscreen stays the same throughout the whole loading process. What am I doing wrong (OnBodyLoad is called - as the name says - when html-body is loaded)?

     

    var xapUrl = "http://myDomain/myXAP.xap";
    var loadingUrl = "http://myDomain/splash.xaml";
    var minRuntime = "4.0.50524.0";
    
    function OnBodyLoad() {
        var silverlightHost;
        var silverlightObject;
        var historyFrame;
    
        silverlightHost = document.getElementById("silverlightControlHost");
    
        silverlightObject = Silverlight.createObject(
                xapUrl,
                silverlightHost,
                "Main",
                {
                    width: "940",
                    height: "350",
                    windowless: "true",
                    MaxFrameRate: "60",
                    background: "white",
                    minRuntimeVersion: minRuntime,
                    autoUpgrade: "true",
                    SplashScreenSource: loadingUrl,
                    enableHtmlAccess: "true",
                    AllowHtmlPopupwindow: "true",
                    alt: altHtml
                },
                {
                    onError: "onSilverlightError",
                    onSourceDownloadProgressChanged: "DownloadProgress"
                },
                null, null)
    
        historyFrame = document.createElement("iframe");
        historyFrame.id = "_sl_historyFrame";
        historyFrame.style.visibility = "hidden";
        historyFrame.style.height = "0px";
        historyFrame.style.width = "0px";
        historyFrame.style.border = "0px";
        silverlightHost.appendChild(historyFrame);
    }
    
    function DownloadProgress(sender, eventArgs) {
        sender.findName("txtLoading").Text = "Anwendung zu " + Math.round(eventArgs.progress * 100) + "% geladen";
        sender.findName("progressBarScale").ScaleX = eventArgs.progress;
    }
    
      
    Thursday, July 1, 2010 9:30 AM

Answers

  • Got it by myself:

    Never host XAP and website within different domains cause obviously download progress ist not registered crossdomain... 

    Monday, July 12, 2010 6:19 AM

All replies

  •  No one out there who can help me?

    Wednesday, July 7, 2010 9:27 AM
  • Got it by myself:

    Never host XAP and website within different domains cause obviously download progress ist not registered crossdomain... 

    Monday, July 12, 2010 6:19 AM
  • Hi meykih,

    I am also facing the same issue. Can you please elaborate the resolution you got? Have you changed any javascript code?

    ~ Ravi

    Monday, January 31, 2011 6:07 AM
  • As I already wrote it is a cross domain problem for which I found no solution except hosting XAP and website under the same domain.

    Monday, January 31, 2011 7:14 AM
  • Hi Maike,

    Thanks for quick responce Smile.

    Actually my XAP and website was hosted in the same domain, still I was facing the issue due to different reason. I was facing this issue only on firefox browser and not on IE. I would like to share resolution with you, as it may help you in future.

    I was creating silverlight object as below -

    Silverlight.createObjectEx(
                        {
                            source: "ClientBin/NmsConsole.xap?rev=1",
                            parentElement: document.getElementById('silverlightControlHost'),
                            id: "silverlightControl",
                            properties:
                            {
                                data: "data:application/x-silverlight-2,",
                                type: "application/x-silverlight-2",
                                width: "0%",
                                height: "0%",
                                background: "LightGray",
                                version: "4.0.50524.0",
                                alt: altHtml,                            
                                autoUpgrade: true
                            },
                            events:
                            {
                                onError: onSilverlightError,
                                onSourceDownloadProgressChanged: onSourceDownloadProgressChanged,
                                onLoad: onSilverlightControlLoaded
                            }
                        });

    The error in above code is line:

    autoUpgrade: true

    I am able to resolve issue just by adding double quotes as:

    autoUpgrade: "true"

    Thank you very much for your help and trigger to my mind.

    ~ Ravi

    Monday, January 31, 2011 8:16 AM