开发者

Silverlight based gadget to open link in a browser?

开发者 https://www.devze.com 2023-02-01 23:58 出处:网络
I have written a sidebar gadget which displays a series of links using silverlight.I can host the silverlight in a web site and when I click on the links they open in a new tab.When I package it up as

I have written a sidebar gadget which displays a series of links using silverlight. I can host the silverlight in a web site and when I click on the links they open in a new tab. When I package it up as a gadget however the links appear in the gadget, and they can be clicked on, but they do not open a browser window to display the link.

What do I need to do to开发者_StackOverflow社区 get this to work?


It's best to launch external links from gadgets using your preferred shell execute method; doing so will launch them in the default browser. When developing gadgets, all my links have an onclick handler which points to the following method:

function launchLink() {
    if (this.href.slice(0,7) == "http://") {
        System.Shell.execute(this.href);
        return false;
    }
}

Theoretically, you could modify this slightly and invoke it from your Silverlight code using the HTML bridge.

JS code

function launchLink(href) {
    System.Shell.execute(href);
}

Silverlight

// HtmlPage requires using System.Windows.Browser
HtmlPage.Window.Invoke("launchLink", "http://some.com/");
0

精彩评论

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