如何在 silverlight 中强制打开新窗口或选项卡
我正在尝试从 Silverlight 应用程序打开一个新窗口或选项卡。 如何强制目标类型(窗口/选项卡)? 现在,当我调用时它使用浏览器默认设置:
HtmlPage.Window.Navigate(new Uri("http://www.google.com"), "_blank");
我正在使用上下文菜单来执行此操作,我希望获得与常规浏览器相同的结果,“在新选项卡中打开”和“在新窗口中打开”。 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请阅读以下有关
HtmlPage.PopupWindow()
的文章:如何弹出浏览器窗口
也是如果使用
Navigate
,则为blank
而不是_blank
。或者,您始终可以从 Silverlight 调用 javascript 函数。创建一个在 javascript 中接受 url 参数的函数,然后从 Silverlight 中调用它,如下所示:
Javascript 函数:
这是最麻烦的,但它具有很大的灵活性来执行其他操作,并可能获得选项卡/窗口的正确感觉。至于指定选项卡或窗口,我认为您不能,因为这是特定于浏览器的,并且可能会根据您使用的浏览器而有所不同。
Read the following article regarding
HtmlPage.PopupWindow()
:How to Popup a Browser Window
Also it is
blank
not_blank
if usingNavigate
.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:
Javascript function:
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.