Results 1 to 20 of 20

Thread: How to open a URL in a new window?

  1. #1

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    How to open a URL in a new window?

    How can I use server-side scripts to open a URL in a new browser window, like a little popup ad?
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    I pretty sure those are all done with client side javascript. Caused a lot of people to turn off javascript...
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    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...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  4. #4
    Lively Member
    Join Date
    Aug 2001
    Posts
    82
    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>
    If you think I am wierd, then thats YOUR problem!

    -----------------------------------

    I keep snakes and lizards, wanna know more? PM me

  5. #5

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    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...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  6. #6
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276
    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.

  7. #7
    Lively Member
    Join Date
    Aug 2001
    Posts
    82
    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...
    Oh okay I see but I don't know VBscript (yet) at this time
    If you think I am wierd, then thats YOUR problem!

    -----------------------------------

    I keep snakes and lizards, wanna know more? PM me

  8. #8
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  9. #9

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    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???
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  10. #10
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Use server-side VBScript to dynamically write client-side Javascript.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  11. #11

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    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?
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  12. #12
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    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.
    Thank you for agreeing with me Jemima.

  13. #13
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276

    Forgot my lines

    Now, wat must i say??

  14. #14
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    I dunno.. I just wanted to thank you for agreeing with me... not many people do..

  15. #15
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276
    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.

  16. #16
    Lively Member
    Join Date
    May 2001
    Posts
    127
    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.

  17. #17

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Cheers

    Thanks everyone for your help.

    I'll see what I can come up with...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  18. #18
    New Member
    Join Date
    May 2003
    Location
    UK - South East
    Posts
    1
    You could use javascript setTimeout. This way you can do a new window at random times...

  19. #19
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345
    rjlohan when you come up with a solution, a workaround do let us know about it.
    Thanks.

  20. #20
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345
    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
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width