开发者

Silverlight window.external.notify() securityproblem?

开发者 https://www.devze.com 2023-01-19 15:54 出处:网络
in my silverlight application I am using the webBrowser control. I call following javascript function on the page i\'m navigating to.

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消