Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open new browser window from vbscript

Status
Not open for further replies.

trids

Programmer
Feb 23, 2001
21
I have a vbscript running in a page where the user provides parameters to dislpay an invoice .. and the vbscript provides the invoice in various ways depending on what the user selects, one of which is to popup a window with the invoice formatted for printing.

The invoice is built by the script on the base page, but I can't find a way to get it displayed in the popup window. I can save the entire page to a Session variable and then launch the popup window from a link tag..
Code:
<-- the base page -->
<% Session("statcli_branded") = sHTML %>
<A href="statcliprint.asp" target="_new" title="Logos and Footers">Print Format</A>
And then display it in statcliprint.asp (the popup window):
Code:
Response.write Session("statcli_branded")

But the client doesn't want the link tag to provide the popup. Instead, I need to launch the popup from the vbscript that builds sHTML (as a result of its processing the input parameters).

So what I'm looking for is probably a way to execute from vbscript the equivalent of the javascript command: window.open('statcliprint.asp', 'windowname'). To this end, I have set up a javascript function and tried to call it from the vbscript
Code:
function brandedpopup()
{
   window.open('statcliprint.asp', 'blah');
   return true;
}
.. but I get an error from vbscript saying it can't find a variable called brandedpopup.

Please help - am I missing something obvious, or do I have to be more devious?



 
Just make a vbs sub to replace js function brandedpopup.
[tt]
sub brandedpopup
window.open "statcliprint.asp", "blah"
window.returnvalue=true
end sub
[/tt]
If you insist on calling a js function, you have to show how you call it. If the page script is js-based, what is more natural to call js function?
 
Thanks for your reply, tsuji. I would certainly oprefer to keep it all vbscript .. but when I tried the vbs "window.open" which you suggested, I got an error:
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'window'
.. This is the only reason I tried to call the js function from the vbs page script.

I have seen documentation on using window.open in vbs, but none of the examples work for me. Is there something special I need to do to instantiate a window-object in vbs?

Could it be a browser issue? I'm meant to be coding for MSIE and FireFox, but can only get into the development site with FireFox.

We're running IIS version 4.02.0788 on the server



 
If you use any vbs on the page, no need to target any audience other than ie. It's not realistic. They do not support it.
 
The vbs is running on the server .. so I assumed this is why the window object wasn't accessible, and why some of the example I've been able to find suggest calling the js (client side) to popup the window.

I'll just explain to them that you can't open a browser window on the client from code running on the server .. and recommend the workaround of the link:
Code:
<A href="statcliprint.asp" target="_new" title="Logos and Footers">Print Format</A>

Thanks for your help :eek:)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top