views:

49

answers:

1

Hi,

in my silverlight application I am using the webBrowser control.

I call following javascript function on the page i'm navigating to.

    function notify() {
        window.external.notify("Close");
    }

The weird fact is that it only works when I am navigating to the page by using:

this.Browser.Source = new Uri("http://localhost/TestOutOfBrowser.Web/HTMLPage1.htm");

When I navigate to it using the real server name:

            this.Browser.Source = new Uri("http://testServerName/TestOutOfBrowser.Web/HTMLPage1.htm");

I get an javascript exception ('Unspecified error.') when executing the window.external.notify("Close"); line.

This is most probably security related but I don't have a clue how to solve this problem..

How can I get this to work?

+1  A: 

For anyone facing the same or similar problem:

Appearantly this is a cross-domain scripting security issue. The browser control will not execute this if the domain of the silverlight application and the page(you are navigating to) are different. (! even 127.0.0.1 and localhost are evaluated as 'different' domains )

I ended up using a Relative URI to browse to the page and this solved my problem.

Grtz

Stephane