Skip to main content

Microsoft Silverlight

Answered Question Open a new Window / Tab / Popup WindowRSS Feed

(0)

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Open a new Window / Tab / Popup Window

Hi all,

I've been experimenting with a solution where I open a new Window/Tab on a click of a Silverlight Button (even better, open a popup window). But though we have a few things available for checking like HtmlPage.IsPopupWindowAllowed.

One of the things I found out, is the usage of HtmlPage.Window.Navigate doesn't work in Google Chrome.

I want to achieve a situation where I can open a new window (either tab / page / popup window) where I will load a Silverlight app as well. The opening is done from within Silverlight as well.

I tried things like: HtmlPage.Window.Eval( string.Format( "window.open('{0}','mywindow','width=200,height=100,scrollbars=yes,toolbar=yes,location=yes'); ", uri));

Maybe someone has an idea I didn't try yet. Please let me know.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

Rjacobs
Rjacobs

Participant

Participant

920 points

155 Posts

Re: Open a new Window / Tab / Popup Window

Create a javascript function using window.open in your silverlight host page then call that from your silverlight app passing the url.  I know it sounds hokey, but it should be compatible with any browser.

Regards,
Rob Jacobs

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Re: Open a new Window / Tab / Popup Window

Thanks, but does this work with popup blockers? Most built-in popup blockers keep in mind, the fact that a click is user-initiated. Just like my first post I used Javascript using Eval, with the same problem, popups were blocked.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

rjacobs
rjacobs

Participant

Participant

920 points

155 Posts

Answered Question

Re: Open a new Window / Tab / Popup Window

I was focusing on the issue with HtmlPage.Window.Navigate not working at all with Google Chrome.  I used the following code to test opening a new browser window:

Javascript in aspx page:

        function openNewWindow(url) {
            window.open(url.toString(), "_blank", "", "");
        }

 

Function in silverlight:

HtmlPage.Window.Invoke("openNewWindow", "http://www.silverlight.net");

This got further then just using the HtmlPage.Window.Navigate and did try to open a new window in Chrome.   Yes, the popup blocker did stop it and asked me to allow the new window, but once I said yes and allowed the site to diplsay popups, I had no problems.  I don't think you are going to get around the popup blocker prompt no matter what technology you are using.

Regards,
Rob Jacobs

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Re: Open a new Window / Tab / Popup Window

Thanks, but the thing that differs so much is comparing it to the experience when clicking a html hyperlink.


We can specify a specific target (without javascript) works like a charm.

If we want to do a popup, we can very easily do this using onclick on a hyperlink. That is working even while using a popup blocker.

It's sad that we don't get the same experience like we already have using HTML.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

soulsolutions
soulsolu...

Member

Member

27 points

10 Posts

Re: Re: Open a new Window / Tab / Popup Window

I've had great success using the <HyperlinkButton> control, setting the TargetName="_blank" and setting the NavigateUri property in code. If you know the address before they click the button (eg on control load or after loading some data) then this seems to work perfectly. I get a new window and no popup warnings.

Windows Live Platform MVP
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities