Results 1 to 5 of 5

Thread: how do I modify this script?

  1. #1
    Join Date
    Jul 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how do I modify this script?

    I have the following script (which technically I got from Dynamic Drive but I couldn't find it again to reference which is why I'm posting here)

    var browser_type=navigator.appName
    var browser_version=parseInt(navigator.appVersion)

    //if NS 4+
    if (browser_type=="Netscape"&&browser_version>=4)
    window.location.replace("http://url")
    //if IE 4+
    else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4)
    window.location.replace("http://url")
    //Default goto page (NOT NS 4+ and NOT IE 4+)
    else
    window.location="http://url"


    Anyway, it works. What I like about it is the action happens onload - without a link having to be clicked or anything.
    What I want it to do is not so much forward the page as open a new window with a defined url when the page the script is on loads.

    So pretty much I want a "open a new window" script but without the necesseity of having to click on a link. Does that make sense?

    Can it be done with this script or do I need a whole new script?

    Thanks!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Most modern browsers block all new windows not generated 'onclick' as pop-ups. You might be happy with an alert or a pop-up box of some kind. What exactly is the point of this? What would be in this new window?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeah - I hadn't thought about pop up blockers.

    I have a mysql database with a lot of articles in it for my business. But some articles that I want included I don't want to reprint because of possible copyright infringement.
    Because of the structure I already have built on the site the easiest way to include them in the database seemed to be to have the title and author information and have the body be code that opens a new window with the article on the author's websites instead of making people click on up to 3 different links just to get to it.
    Last edited by Angyl; 07-22-2005 at 04:08 PM.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You can construct a link that will fire two page loads:
    HTML Code:
    <a href="somepage.htm" onclick="window.open('another.htm');return true;">Dual Link</a>
    That shouldn't arouse the pop up blockers on all but the tightest security settings. This one may activate blocking but fires three links:
    HTML Code:
    <a href="somepage.htm" onmousedown="window.open('another.htm');return true;" onmouseup="window.open('yetanother.htm');return true;">Triple Link</a>
    If you want the anchor link to open in a new window as well, add targeting:
    HTML Code:
    <a href="somepage.htm" target="_blank" onclick="window.open('another.htm');return true;">Dual Link</a>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    cool. thank you.

Bookmarks

Posting Permissions

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