HobbyTown
asked on
How to open a second asp web page?
Hi,
I am using
response.redirect("http://google.com")
to open a new asp web page. The result is: the original web page disappears and it is replaced by the new Google.com page.
What I want to do is:
Keep the original web page, and open the sencond page of Google.com.
I am using vbscript. How can I do that? Any ideas?
Thanks a lot.
< a href="google.com" target=="_new">Click</a>
You can use JavaScript:
<%
If SomeCondition = True Then
Response.Write("<script language=""Javascript"">")
Response.Write("window.ope n('http://www.google.com');")
Response.Write("</script>" )
End If
%>
However, this will be defeated by popup blockers. Jitganguly's solution wouldn't be defeated, but requires the user click event.
<%
If SomeCondition = True Then
Response.Write("<script language=""Javascript"">")
Response.Write("window.ope
Response.Write("</script>"
End If
%>
However, this will be defeated by popup blockers. Jitganguly's solution wouldn't be defeated, but requires the user click event.
ASKER
How can I put
< a href="google.com" target=="_new">Click</a>
into the vbscript codes and how to automatically redirect this new web page? Thanks.
< a href="google.com" target=="_new">Click</a>
into the vbscript codes and how to automatically redirect this new web page? Thanks.
ASKER
But the error information is:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
How to solve that? Thanks
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
How to solve that? Thanks
ASKER
I find that "window" can not be used in my vbscript. any ideas? Thanks.
This works for me:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>open window with VBSCRIPT</title>
<SCRIPT LANGUAGE="VBSCRIPT">
Public oWin
Sub cmdOpenWin_OnClick()
Set oWin = Window.Open("http://www.google.com", "NewWin")
End Sub
Sub cmdCloseWin_OnClick()
if oWin Is Nothing Then
MsgBox "Window not instantiated!"
Else
oWin.Close
End If
End Sub
</SCRIPT>
</head>
<body>
<FORM NAME="frmWin1" ACTION="" METHOD="POST">
Manage a new Internet Explorer window:
<INPUT TYPE="button" NAME="cmdOpenWin" VALUE="Open New Window">
<INPUT TYPE="button" NAME="cmdCloseWin" VALUE="Close Window">
</FORM>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>open window with VBSCRIPT</title>
<SCRIPT LANGUAGE="VBSCRIPT">
Public oWin
Sub cmdOpenWin_OnClick()
Set oWin = Window.Open("http://www.google.com", "NewWin")
End Sub
Sub cmdCloseWin_OnClick()
if oWin Is Nothing Then
MsgBox "Window not instantiated!"
Else
oWin.Close
End If
End Sub
</SCRIPT>
</head>
<body>
<FORM NAME="frmWin1" ACTION="" METHOD="POST">
Manage a new Internet Explorer window:
<INPUT TYPE="button" NAME="cmdOpenWin" VALUE="Open New Window">
<INPUT TYPE="button" NAME="cmdCloseWin" VALUE="Close Window">
</FORM>
</body>
</html>
Note: Client-side VBscript will only work in IE. Javascript works on multiple platforms/browsers.
ASKER
Hi raj3060,
Thanks for your answers. I tried your example as an independent program, and it indeed works. However, when I put it into my program, it does not work. The problem is : in my program, "window" object can not be recognized, but in the independent file, window" object can be recognized. How can change anything my program to solve that? Thanks.
Thanks for your answers. I tried your example as an independent program, and it indeed works. However, when I put it into my program, it does not work. The problem is : in my program, "window" object can not be recognized, but in the independent file, window" object can be recognized. How can change anything my program to solve that? Thanks.
Could you post the code where you are trying to add this code.
Also, can you use javascript?
Also, can you use javascript?
here is an idea, assume you get the post from A.asp, and you want to open another window to www.google.com, and you want to disaply a.asp as well.
so, do not use response.redirect, instead set a flag to tell the <body onload=> function.
code sample will look like below, please let me know if you have question.
<%
if request.form <> "" then
'your process code
'response.redirect ("www.google.com") <----- don't redirect here, set the flag to 1
FlagToOpenWindow=1
else
FlagToOpenWindow=0 <---- if it is normal load, set the flag to 0, so body onload will not pop up another window
end if
%>
<script language=JavaScript>
function OpenAnotherWindow(a)
if a==1
{
window.open("http://www.google.com", "NewWindow", 'toolbar,width=150,height= 100')
}
</script>
<html>
<body onload = OpenAnotherWindow(<%=FlagT oOpenWindo w%>)>
</body>
</html>
so, do not use response.redirect, instead set a flag to tell the <body onload=> function.
code sample will look like below, please let me know if you have question.
<%
if request.form <> "" then
'your process code
'response.redirect ("www.google.com") <----- don't redirect here, set the flag to 1
FlagToOpenWindow=1
else
FlagToOpenWindow=0 <---- if it is normal load, set the flag to 0, so body onload will not pop up another window
end if
%>
<script language=JavaScript>
function OpenAnotherWindow(a)
if a==1
{
window.open("http://www.google.com", "NewWindow", 'toolbar,width=150,height=
}
</script>
<html>
<body onload = OpenAnotherWindow(<%=FlagT
</body>
</html>
ASKER
Hi ,
In face, I changed <SCRIPT LANGUAGE="VBSCRIPT"> ...</SCRIPT>
to <%@ LANGUAGE = VBScript %> .. <% ...%>
The following codes are the same as raj3060's codes listed above, except that he uses <SCRIPT LANGUAGE="VBSCRIPT"> ...</SCRIPT> .
For his above code, "window" is enabled, and the whole program works, however, for my following codes, it doesn't work, since "window" is disenabled.
Any ideas about the difference? How to enable "window" object under <%@ LANGUAGE = VBScript %> .. <% ...%> ?
Thanks.
<%@ LANGUAGE = VBScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>open window with VBSCRIPT</title>
<%
Public oWin
Sub cmdOpenWin_OnClick()
Set oWin = Window.Open("http://www.google.com", "NewWin")
End Sub
Sub cmdCloseWin_OnClick()
if oWin Is Nothing Then
MsgBox "Window not instantiated!"
Else
oWin.Close
End If
End Sub
%>
</head>
<body>
<FORM NAME="frmWin1" ACTION="" METHOD="POST">
Manage a new Internet Explorer window:
<INPUT TYPE="button" NAME="cmdOpenWin" VALUE="Open New Window">
<INPUT TYPE="button" NAME="cmdCloseWin" VALUE="Close Window">
</FORM>
</body>
In face, I changed <SCRIPT LANGUAGE="VBSCRIPT"> ...</SCRIPT>
to <%@ LANGUAGE = VBScript %> .. <% ...%>
The following codes are the same as raj3060's codes listed above, except that he uses <SCRIPT LANGUAGE="VBSCRIPT"> ...</SCRIPT> .
For his above code, "window" is enabled, and the whole program works, however, for my following codes, it doesn't work, since "window" is disenabled.
Any ideas about the difference? How to enable "window" object under <%@ LANGUAGE = VBScript %> .. <% ...%> ?
Thanks.
<%@ LANGUAGE = VBScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>open window with VBSCRIPT</title>
<%
Public oWin
Sub cmdOpenWin_OnClick()
Set oWin = Window.Open("http://www.google.com", "NewWin")
End Sub
Sub cmdCloseWin_OnClick()
if oWin Is Nothing Then
MsgBox "Window not instantiated!"
Else
oWin.Close
End If
End Sub
%>
</head>
<body>
<FORM NAME="frmWin1" ACTION="" METHOD="POST">
Manage a new Internet Explorer window:
<INPUT TYPE="button" NAME="cmdOpenWin" VALUE="Open New Window">
<INPUT TYPE="button" NAME="cmdCloseWin" VALUE="Close Window">
</FORM>
</body>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
you will also need this:
<INPUT TYPE="button" NAME="cmdOpenWin" VALUE="Open New Window" onclick = "cmdOpenWin_OnClick">
<INPUT TYPE="button" NAME="cmdCloseWin" VALUE="Close Window" onclick = "cmdCloseWin_OnClick" >
<INPUT TYPE="button" NAME="cmdOpenWin" VALUE="Open New Window" onclick = "cmdOpenWin_OnClick">
<INPUT TYPE="button" NAME="cmdCloseWin" VALUE="Close Window" onclick = "cmdCloseWin_OnClick" >
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Any luck? :)