Skip to main content

Microsoft Silverlight

Safari pop up windows problem in silverlight 2RSS Feed

(0)

kashifimran
kashifimran

Member

Member

74 points

46 Posts

Safari pop up windows problem in silverlight 2

I am trying to open a pop window from silverlight app which than loads a new aspx page. It works with IE and Firefox but gives error in Safari. Below is the C# code that is inside button click event handler and after that is the javascript code to open pop up window. I took javascript from one Joe Stagner's blogs. I have tried it on both windows and mac and Safari does not seem to work on either one.

try

{

ScriptObject myScriptMethod = (ScriptObject)HtmlPage.Window.GetProperty("wopen");myScriptMethod.InvokeSelf("../Management/UploadContent.aspx", "Content", 500, 300);

}

catch(Exception ex)

{

ScriptObject myScriptMethod = (ScriptObject)HtmlPage.Window.GetProperty("sayHi");

myScriptMethod.InvokeSelf(ex.Message);

}

 

 

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<
script type="text/javascript">
<!--
function sayHi(msg)
{
alert(msg);
}
 

var updated="";
function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.

// In my tests these work well on all platforms & browsers.

w += 32;

h += 96;

wleft = (screen.width - w) / 2;

wtop = (screen.height - h) / 2;

// IE5 and other old browsers might allow a window that is

// partially offscreen or wider than the screen. Fix that.

// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {

w = screen.width;

wleft = 0;

}

if (wtop < 0) {

h = screen.height;

wtop = 0;

}

var win = window.open(url,

name,

'width=' + w + ', height=' + h + ', ' +

'left=' + wleft + ', top=' + wtop + ', ' +

'location=no, menubar=no, modal=yes' + 'status=no, toolbar=no, scrollbars=no, resizable=no', 'tite=no', 'resizable=no', 'directories=no', 'status=no');

// Just in case width and height are ignored

win.resizeTo(w, h);

// Just in case left and top are ignored

win.moveTo(wleft, wtop);

win.focus();

}

// -->

</script>

</asp:Content>

kashifimran
kashifimran

Member

Member

74 points

46 Posts

Re: Safari pop up windows problem in silverlight 2

I also tried HyperLinkButton and it works on safari if you are navigating in the same window. If you set TargetName="New" IE and Firefox open link in new window. Safari does not do anything again on both windows and mac.

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Re: Re: Safari pop up windows problem in silverlight 2

Hello, are you using Safari on Windows or Mac? Currently only Safari on Mac is supported. Safari on Windows may work fine for some Silverlight applications, but not all, especially if you use a lot of scripts...

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

kashifimran
kashifimran

Member

Member

74 points

46 Posts

Re: Re: Safari pop up windows problem in silverlight 2

It does not work on both mac or pc. I noticed if I call a function from SL that in turn invoke a button's click event and if my open window logic is inside button's click event handler then it works.

//Calling stub javascrtip from silverlight
HtmlPage.Window.Invoke("Stub");

In host asp.net page I have fowlling javascript and a hidden button.

//Stub invoke btnSafari's click event
function Stub() //Test function
{
var btn = document.getElementById('btnSafari');
if(btn != null)
  btn.click();
}

Open new window
function pop() //Test function
{
url =
'http://www.google.com';
window.open(url,
'New');
}

//Hidden button to open pop up in safari.
<input id="btnSafari" style="visibility: hidden; height: 0px; width: 0px;" type="button" onclick="pop(); return false;" />

 

kashifimran
kashifimran

Member

Member

74 points

46 Posts

Re: Re: Safari pop up windows problem in silverlight 2

Following does not work for safari

//Calling stub javascrtip from silverlight
HtmlPage
.Window.Invoke("pop");

prithwish.ghosh
prithwis...

Member

Member

8 points

4 Posts

Re: Safari pop up windows problem in silverlight 2

You are talking about the popup. My whole application is not running in Safari....

 

Please help me out....Sad

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities