Skip to main content

Microsoft Silverlight

Answered Question Show new browser windowRSS Feed

(0)

JasonLP
JasonLP

Member

Member

16 points

14 Posts

Show new browser window

I'd like to have a new browser window popup with a given URL when the user clicks on a certain UI element.  Is this possible?  In .NET, I know I can use System.Diagnostics.Process.Start(), but this isn't available in the Silverlight realm.  I know I can also use System.Windows.Browser.HtmlPage.Navigate(), but this replaces the current page (wiping out the Silverlight control), which is not what I need either.  Is there any way to load a page into a new browser window? 

Thanks!

-Jason- 

chad.campbell
chad.cam...

Participant

Participant

1918 points

332 Posts

Silverlight MVP

Re: Show new browser window

Hi Jason,

This is possible.  If you are using JavaScript to handle your logic, on a ui element click, you can use the HTML DOM to launch a new browser window.  Here is some reference: http://www.w3schools.com/htmldom/met_win_open.asp

 If this answers your question, please select "mark as answer"

Thank you,

Chad Campbell

If this answers your question, please select "mark as answer", otherwise, please post a follow up question. Thanks!
Chad Campbell

Author of Silverlight 2.0 in Action Blog: http://cornucopia30.blogspot.com

JasonLP
JasonLP

Member

Member

16 points

14 Posts

Re: Show new browser window

I am using C# to handle the logic.  Is there a way to call into a Javascript function on the page that is hosting the Silverlight control?

chad.campbell
chad.cam...

Participant

Participant

1918 points

332 Posts

Silverlight MVP

Re: Show new browser window

Hi Jason,

I have not had a chace to play with the 1.1 framework yet.  I hope to soon.  I would recommend looking in the "System.Windows.Browser" namespace.  But I do not know 

http://download.microsoft.com/download/f/2/e/f2ecc2ad-c498-4538-8a2c-15eb157c00a7/SL_Map_FinalNET.png

If this answers your question, please select "mark as answer", otherwise, please post a follow up question. Thanks!
Chad Campbell

Author of Silverlight 2.0 in Action Blog: http://cornucopia30.blogspot.com

Dave Relyea
Dave Relyea

Participant

Participant

1084 points

249 Posts

Microsoft

Re: Show new browser window

See my blog post for one way to call JS from C#.

http://blogs.msdn.com/devdave/archive/2007/05/21/calling-javascript-from-c.aspx

huanwu
huanwu

Member

Member

152 points

32 Posts

Answered Question

Re: Show new browser window

If you use HtmlPage.Navigate("http://www.msn.com", "new window"), then it will not replace the current page but pop up with a new window named "new window".

 

 

JasonLP
JasonLP

Member

Member

16 points

14 Posts

Re: Re: Show new browser window

Dave,

This works great.  Thank you!

-Jason-

JasonLP
JasonLP

Member

Member

16 points

14 Posts

Re: Re: Show new browser window

I didn't know this overload existed.

Thanks for this!

-Jason-

dumbledad
dumbledad

Member

Member

38 points

8 Posts

Re: Show new browser window

That almost works for me.

System.Windows.Browser.HtmlPage.Navigate("http://silverlight.net/", "new window");

causes a COMException in the SilverLight DLL with the additional information "Navigate failed". But

System.Windows.Browser.HtmlPage.Navigate("http://silverlight.net/", "_blank");

opens the Silverlight homepage in a new tab, though the browser does not swap to it. Are the target options for System.Windows.Browser.HtmlPage.Navigate documented anywhere?

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities