开发者

How to force new window or tab in silverlight

I am trying to open a new window or tab from my Silverlight application. How can I force the target type (window/tab)? Right now, it's using the browser default settings when开发者_运维知识库 I call:

HtmlPage.Window.Navigate(new Uri("http://www.google.com"), "_blank");

I am using context menu to do this and I would like to have the same results as in a regular browser, "Open in new tab" and "Open in new window". Thanks


Read the following article regarding HtmlPage.PopupWindow():

How to Popup a Browser Window

Also it is blank not _blank if using Navigate.

Alternatively you can always call a javascript function from Silverlight. Create a function that takes a url paramater in javascript and then just call it from Silverlight like:

HtmlPage.Window.Invoke("OpenMyNewWindow", new string[] { "http://www.google.com" });

Javascript function:

function OpenMyNewWindow(url)
{
    window.open(url, "nameOfWindow");
}

This is the most cumbersome but it has lots of flexibility to do other stuff and possibly get the right feel for tab / window. As for dictating a tab or window I don't think you can as that is specific to the browser and could be diff depending on which browser you are using.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜