Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Launch new explorer window using VBscript

Posted on 2001-08-15
21
Medium Priority
?
2,399 Views
Last Modified: 2010-07-27
How do I launch a new explorer window and have it load a supplied file from an ASP page using VBscript?
0
Comment
Question by:BryanC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 2
  • +4
21 Comments
 
LVL 8

Expert Comment

by:drittich
ID: 6389675
<html>
<head>
<title></title>
</head>
<body>
<script language="vbscript">
     Function DoIt()
          window.open("http://www.google.com/")
     End Function
</script>
<input type=button onClick="DoIt()" value="go">

</body>
</html>
0
 
LVL 8

Expert Comment

by:drittich
ID: 6389677
of course you can use YourFile.asp rather than http://www.google.com
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6389680
<SCRIPT LANGUAGE="VBScript">
Dim objIE
Set objIE = CreateObject("InternetExplorer.Application")

With objIE
  .Visible = True
  .Navigate "your.asp?params"
end with  
</SCRIPT>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:John844
ID: 6389688
you can also just create a hyperlink with a target like

<a href="myaspPage.asp" target="_new">new window</a>

this method will not let you control size or appearance of the new window.
0
 

Author Comment

by:BryanC
ID: 6389734
Thanks for the quick response. I can get your examples working in a .html file but not a .ASP file. Do you know what I am missing?
0
 
LVL 5

Expert Comment

by:raizon
ID: 6389735
Okay lets have some fun and throw in one more way.

<script languange="VBScript")

Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run("iexplore http://www.microsoft.com")

</script>
0
 
LVL 7

Expert Comment

by:John844
ID: 6389759
should work exactly the same.  show us the code that is not working from the asp page.
0
 

Author Comment

by:BryanC
ID: 6389802
My test file has one line.

<%window.open("http://www.google.com/")%>

I receive the following message.
   Microsoft VBScript runtime error '800a01a8'
   Object required: 'window'

0
 
LVL 5

Expert Comment

by:raizon
ID: 6389827
What you are trying is client side script and can't be run from the server ( <% %> ) are dilimeters that tell the server to run the enclosed code.

Change it to
<script language="vbScript">
Window.Open("http://www.google.com/")
</script>
and place that in the head of your document to use this example.  Or as drittich as explained.
0
 

Author Comment

by:BryanC
ID: 6389910
I have a .ASP page that gets user input to generate some reports using server side scripting. Once the report is complete I wanted to launch a new explorer window to view the reports.

<%
...vb code
If (GenReport = "Pressed") Then
   ...vb code to generate report
   ??? want to launch new explorer window here ???
Else
   ...vb code
   %>
   <form action="<%= strURL %>" method="post">
   ... collect user input viw form
   <input type="submit" Name="GenReport" Value="Pressed"/>
   %>
End If
0
 
LVL 5

Expert Comment

by:raizon
ID: 6389971
okay we need to change things up just a bit here.

<%
  If Request.Form("GenReport") = "Pressed" Then
   'code to generate report
  Else
   'vbcode
%>
  <form action="method="post" onSubmit="Javascript: Window.Open ("<%= strURL %>", "Window Title", "height=400, width=200">
  ... collect user input viw form
  <input type="submit" Name="GenReport" Value="Pressed"/>
<%
  End If
%>

Make sure that strURL is the same page as the one that contains this code.  In otherwords you are posting back to the same page.

You have to open the new window via client side and not server side.
0
 
LVL 5

Expert Comment

by:raizon
ID: 6389979
ooops........the form should look like this
<form action="" method="post" onSubmit="Javascript: Window.Open ('<%= strURL %>', 'Window Title', 'height=400,
width=200');">
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6390978
You can also do it with a HREF tag;

<a href="javascript:window.open('page.asp?name=fred&town=bedrock');">Click here Fred</a>

Of course you will have to change the URL values to vars;

<a href="javascript:window.open('page.asp?name=<%=rs("name")%>&town=<%=rs("town")%>');">Click here <%=rs("name")%></a>

0
 

Author Comment

by:BryanC
ID: 6392439
Is there a way to launch the new window without the user pressing a key?

I have a form that they will use to enter data and when they press the Generate button it will call itself. When it is called, if the Generate button was pressed it will generate the report using vbScript, I then want it to launch a new explorer window to view the report, and the current window should be ready for additional data entry.
0
 

Author Comment

by:BryanC
ID: 6392502
Forget the last comment. After looking at it again I understand what you said. I will try it out.

Thanks.
0
 

Author Comment

by:BryanC
ID: 6392683
I setup the following test and it displays "Generate the report and view it in this new window." in the same explorer window instead of launching a new one. Do you have any ideas? Thanks.

<%
Dim strURL
strURL    = Request.ServerVariables("URL")
GenReport = Request.Form("GenReport")
If (GenReport <> "Pressed") Then
   %>
   <form action="" method="post" onSubmit="Javascript: Window.Open ('<%= strURL %>',
    'Window Title', 'height=400, width=200');">
      I should collect user data here.
      <input type="submit" Name="GenReport" Value="Pressed" />
   </form>
   <%
Else
   %>    
   Generate the report and view it in this new window.
   <%
End If
%>
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6393183
You can use the onMouseOver="window.open('page.asp')" event to launch a new window.
0
 

Accepted Solution

by:
BryanC earned 0 total points
ID: 6394241
I got it to work with the following code.

<%
Dim strURL
strURL = Request.ServerVariables("URL")
GenIt  = Request.Form("GenIt")
If (GenIt <> "Pressed") Then
  %>
  <form "<%=strURL%>" target="UniqueName" method="post">
     I should collect user data here.
     <input type="submit" Name="GenIt" Value="Pressed" />
  </form>
  <%
Else
  %>    
  Generate the report and view it in this new window.
  <%
End If
%>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 8672580
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[PAQ with NO REFUND]

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

hongjun
EE Cleanup Volunteer
0
 

Author Comment

by:BryanC
ID: 8681246
Please delete.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question