Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > HTMLPlaceHolder > Howto know when the DOM is loaded and ready

Not answered Howto know when the DOM is loaded and ready

Feed from this thread
  • Pascal avatar

    Posted on Nov 30, 2011 (permalink)

    Hi all,
    I load a html site into the radhtmlplaceholder which contains JS Function that I have to call to initialize the Html page. How do i know when the js functions are completely loaded and ready for use?

    When i call them to early, the browser raises an exception which gets shown to the user and that is not really nice.

    I call the JS in my Loaded Html page with the following method

    var serializedContext = JsonConvert.SerializeObject(dtoPoolPartyContext);
    string code = String.Format("document.getElementById('myIFrame').contentWindow.App.setContext({0});", serializedContext);
    try
    {
       var output = HtmlPage.Window.Eval(code);
    }

    Does someone have a suggestion how to achieve that?

    I think of the following workarounds,
    -Poll the site for a special tag in the dom, so then i know when it's ready
    -Set the frontend to a defined sleeptime (5 seconds or so)  which is really ugly


    Cheers
    Pascal

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on Dec 2, 2011 (permalink)

    Hello Pascal,

     One workaround I can come up with is to listen for the onload event of the HTML page and from the event handler of the onload event to call your Silverlight method.

    Bellow are some links you might consider useful:

    HTML Bridge: Interaction Between HTML and Managed Code

    Walkthrough: Calling JavaScript from Managed Code

    Walkthrough: Calling Managed Code from JavaScript

    Calling Javascript functions from RadHtmlPlaceholder

    All the best,
    Kiril Stanoev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > HTMLPlaceHolder > Howto know when the DOM is loaded and ready
Related resources for "Howto know when the DOM is loaded and ready"

Silverlight HtmlPlaceHolder Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]