How can I use server-side scripts to open a URL in a new browser window, like a little popup ad?
Printable View
How can I use server-side scripts to open a URL in a new browser window, like a little popup ad?
I pretty sure those are all done with client side javascript. Caused a lot of people to turn off javascript...
I know how to do it with JavaScript. But I need (want) to do it with VBScript if I can.
The reason is that I have a little script which displays a pop-up window (it isn't really an ad - its a 'tip' relevant to the site, and I don't want people to miss them by turning off JS).
But I will be adding new tip windows now and then, and my script opens one randomly by using an index which is established by counting the number of files in the directory.
I think I may have to do some DB work, but I didn't really want to for something so simple...
this is simple HTML. No fancy scripting required here, unless you want more work for your self :)
Just add target="_blank"
Code:<a href="link.htm" target = "_blank">Open new window</a>
I know HTML.
I need the windows to open automatically and randomly, so I don't want to use the simple HTML code.
I need a way with JavaScript or VBScript...
So, as chris suggested use :
window.open("NewWin.asp","regwin","TOOLBAR=NO,LOCATION=NO,DIRECTORIES=NO,STATUS=NO,MENUBAR=NO,SCROLL BARS=NO,RESIZABLE=NO,WIDTH=400,HEIGHT=450,MAXIMISE=NO");
Set the attributes of your choice.
- Jemima.
Oh okay I see :) but I don't know VBscript (yet:)) at this time :(Quote:
Originally posted by rjlohan
I know HTML.
I need the windows to open automatically and randomly, so I don't want to use the simple HTML code.
I need a way with JavaScript or VBScript...
You want to use JavaScript for evil. I cannot allow that. :)
If you do this in VBScript then only the IE section of your audience will see it. No other browser supports VBScript.
It is not evil. I only likened my usage to ads because of the random pop-up deal. In fact, I am using these popup windows for a legitimate purpose - it is to give a random tip to visitors to the company site. People want these tips...
Anyways. I'd prefer to use Server-Side VBScript. Netscape users can view the results of a server-side VBScript process in ASP Pages. And I really need to use VBScript to approach it the way I am, because as far as I know, JavaScript doesn't have any of the counting files functions I am using.
The only other way I can see to approach the problem is to use a database, which I am not keen to do, for a number of reasons, the main one being that the length of text varies considerably from tip to tip, and I don't really want to write compex scripts to pull the required text out of a db. Its easier for me to just put up a new tip page and have the script count them and choose one to display. That is all done, but I need the popup functionality of JavaScript...
ANYONE???
Use server-side VBScript to dynamically write client-side Javascript.
I'd considered doing that.
I got my VBScript to write the appropriate JS function into the header, but I couldn't work out how to then call that function automatically. Putting a call in the <BODY> tag (i.e - onLoad = function() ) didn't seem to work...
How would I implement this suggestion?
Thank you for agreeing with me Jemima. :)Quote:
Originally posted by JemimaChadwick
So, as chris suggested use :
window.open("NewWin.asp","regwin","TOOLBAR=NO,LOCATION=NO,DIRECTORIES=NO,STATUS=NO,MENUBAR=NO,SCROLL BARS=NO,RESIZABLE=NO,WIDTH=400,HEIGHT=450,MAXIMISE=NO");
Set the attributes of your choice.
- Jemima.
Now, wat must i say??
I dunno.. I just wanted to thank you for agreeing with me... not many people do.. :)
hey chris, u r right. Not many ppl do. I wanted to acknowledge ur thanks. That too many ppl don't. Well lets say, "We'll stand by the RIGHT (or left??)"
k cool! :)
- Jemima.
Actually I dunno if the Question was ever answered, but no you can not do it with server side script. Pretty simple way of thinging about it. You want to open a window on the Client Side. ASP is Server Side. there is nothing you can do on the server side to make things happen on the client side.
You need to use Javascript to do this. Plain and simple. That's it. You can use the serverside to write the javascript dynamically but that is it.
You can do it with VBscript on the client side, however, the requirements for it is not and IE browser like was said previously because there are IE browsers for Mac, and Unix and Linux. but the requirement is a Microsoft Windows Operating System. Netscape will run VBscript clientside too as long as it is on a windows.
Thanks everyone for your help.
I'll see what I can come up with...
You could use javascript setTimeout. This way you can do a new window at random times...
rjlohan when you come up with a solution, a workaround do let us know about it.
What i can think of is that u make - the script and subroutine on the fly using vbscript..something like this...and call it on some event..
<% crlf = chr(10) & chr(13)
response.write "<script>" & crlf
response.write "sub openwindow" & crlf
response.write "window.open " & chr(34) & "URL..." & chr(34) & crlf
response.write "end sub" & crlf
response.write "</script>" & crlf %>
hope i understood ur problem and making some sense