C
Chris Leffer
Hi.
I wrote a small routine that opens popup windows. The code works well,
but I did a small change to center the popup window and this change does
not work. I can't understand why. That's the code:
Public Shared Sub Popup(ByVal page As Page, ByVal url As String, ByVal
title As String, ByVal width As Short, ByVal height As Short, ByVal
scroll As Boolean, Optional ByVal QueryString As String = Nothing)
Dim strWindow As New StringBuilder
With strWindow
.Append("<SCRIPT LANGUAGE=javascript for=window>" &
ControlChars.NewLine)
.Append("var nTam=" & width & ";" &
ControlChars.NewLine)
.Append("var nAlt=" & height & ";" &
ControlChars.NewLine)
.Append("var nXpos = (screen.availWidth - nTam) / 2;" &
ControlChars.NewLine)
.Append("var nYpos = (screen.availHeight - nAlt) / 2;" &
ControlChars.NewLine)
.Append("window.open('" & url & QueryString & "','" &
title & "','toolbar=no,location=no,status=no,menubar=no,resizable=no,
scrollbars=" & IIf(scroll, "yes", "no") & ",width=" & width & ",height="
& height & ",top=nYpos,screenY=nYpos,left=nXpos,screenX=nXpos');")
.Append("</SCRIPT>")
End With
page.RegisterStartupScript("win", strWindow.ToString)
End Sub
I tried to create the routine to work with both IE and Netscape. When I
run the code, the window always opens at left=0 and top=0. It seems to
ignore the variables.
Can anyone help me to detect the error?
Regards,
Chris Leffer
I wrote a small routine that opens popup windows. The code works well,
but I did a small change to center the popup window and this change does
not work. I can't understand why. That's the code:
Public Shared Sub Popup(ByVal page As Page, ByVal url As String, ByVal
title As String, ByVal width As Short, ByVal height As Short, ByVal
scroll As Boolean, Optional ByVal QueryString As String = Nothing)
Dim strWindow As New StringBuilder
With strWindow
.Append("<SCRIPT LANGUAGE=javascript for=window>" &
ControlChars.NewLine)
.Append("var nTam=" & width & ";" &
ControlChars.NewLine)
.Append("var nAlt=" & height & ";" &
ControlChars.NewLine)
.Append("var nXpos = (screen.availWidth - nTam) / 2;" &
ControlChars.NewLine)
.Append("var nYpos = (screen.availHeight - nAlt) / 2;" &
ControlChars.NewLine)
.Append("window.open('" & url & QueryString & "','" &
title & "','toolbar=no,location=no,status=no,menubar=no,resizable=no,
scrollbars=" & IIf(scroll, "yes", "no") & ",width=" & width & ",height="
& height & ",top=nYpos,screenY=nYpos,left=nXpos,screenX=nXpos');")
.Append("</SCRIPT>")
End With
page.RegisterStartupScript("win", strWindow.ToString)
End Sub
I tried to create the routine to work with both IE and Netscape. When I
run the code, the window always opens at left=0 and top=0. It seems to
ignore the variables.
Can anyone help me to detect the error?
Regards,
Chris Leffer