Call WPF Webbrowser invokescript() when application just loaded

3

I've been trying to call an invokescript on WPF when the application just loaded. I passed in the parameter that I get from the database to invokescript after the WPF has been loaded. However, I keep getting Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME)) error. I loaded the webbrowser control and add navigated event control.

        Uri uri = new Uri(@"pack://application:,,,/Navigator.htm");
        Stream source = Application.GetContentStream(uri).Stream;
        wbNavigator.NavigateToStream(source);

        wbNavigator.Navigated +=new NavigatedEventHandler(wbNavigator_Navigated);

I also tried Loaded() event, LoadCompleted() but none of them work. I did some research and most of them says because the webbrowser control is not initialized yet. I even try to call the invokescript using a separate thread and use sleep() for few seconds but it still doesn't work.

There should be a way to call invokescript() when the WPF just first loaded. I can get it to work if I click on a button that call the invokescript if the WPF application has already loaded.

wpf
browser
loaded
asked on Stack Overflow Apr 11, 2012 by violato

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0