I'm trying to open a new window from an existing window during the refresh of
the first window, but can't get this to work for some reason. An alert()
works, but not window.open. Here is the code:
<%@ Page language="c#" Codebehind="Home.aspx.cs" AutoEventWireup="false"
Inherits="WebReports.Home" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Home</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<P>Welcome<P>Please start by selecting one of the options below.</P>
</form>
<script>
window.open("http://www.microsoft.com", "ms");
</script>
</body>
</HTML>
If I replace the window.open with an alert, that works fine. What am I
doing wrong?
Thanks in advance.
Parijat - 28 Apr 2005 20:43 GMT
<script>
function newWindow() {
window.open("http://www.microsoft.com", "ms");
}
</script>
<body onload="newWindow()">
Try this
Gridlock - 28 Apr 2005 21:24 GMT
Thanks for the suggestion, but unfortunately this did not work.
Gridlock - 29 Apr 2005 16:06 GMT
Interestingly, 'onfocus' works but of course has problems in this context
since closing the popup and returning the focus to the main window
automatically reopens the popup. I don't understand why 'onload' doesn't
work. Any other suggestions?
Parijat - 28 Apr 2005 20:43 GMT
Try This
Put the window.open in a javascript function and call that function from the
main page's body onload event