Results 1 to 5 of 5

Thread: Opening https links in new window

  1. #1
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Opening https links in new window

    1) Script Title:
    Open offsite links in new window script

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...newwindow2.htm

    3) Describe problem:
    Open offsite links in new window script is amazing, but it doesn't seem to work with https links. Works perfectly with http links.

    Is it possible to modify the JS file to allow this? If so, would you be so kind as to show me what line and where?

    Hoping you can help.

    Cheers

    Mike

  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

    In the ddwindowlinks.js script, line #25:

    Code:
    			if (all_links[i].hostname.search(rexcludedomains)==-1 && all_links[i].href.indexOf("http:")!=-1)
    Using a text only editor like NotePad, change that to:

    Code:
    			if (all_links[i].hostname.search(rexcludedomains)==-1 && /^http/.test(all_links[i].href))
    Save and use that version. It will work for both http and https, any href that begins with http and is not excluded.

    The browser cache may need to be cleared and/or the page refreshed to see changes.
    - John
    ________________________

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

  3. #3
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks so much for getting back to me. I really appreciate it.

    Your solution is almost perfect except now it opens local pages in new windows. For example local pages target _blank rather than _self.

    Is there a work around for this?

    Thanks

    Mike
    www.miketosetto.com
    Last edited by jscheuer1; 08-19-2013 at 03:19 PM. Reason: Format

  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

    Ah, I see, the demo page neglects to clearly tell that you have to edit the excludedomains property in ddwindowlinks.js.

    Again using NotePad or similar, change (from the top of the file):

    Code:
    //Open offsite links in new window script- http://www.dynamicdrive.com/
    //Created: August 28th, 2007'
    
    var ddwindowlinks={
    //1)Enter domains to be EXCLUDED from opening in new window:
    excludedomains: ["dynamicdrive.com", "google.com"],
    
    //2) Target for links that sho . . .
    to:

    Code:
    //Open offsite links in new window script- http://www.dynamicdrive.com/
    //Created: August 28th, 2007'
    
    var ddwindowlinks={
    //1)Enter domains to be EXCLUDED from opening in new window:
    excludedomains: ["miketosetto.com"],
    
    //2) Target for links that sho . . .
    Save and use that file.

    The browser cache may need to be cleared and/or the page refreshed to see changes.
    - John
    ________________________

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

  5. #5
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John, thanks for getting back to me so quickly and thanks again for taking the time to help.

    Your solution works a treat.

    Cheers

    Mike

Similar Threads

  1. Accordion script not opening in https: ?
    By MTuttle in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 11-19-2012, 10:12 PM
  2. Opening New Window Through Links
    By lschena in forum JavaScript
    Replies: 2
    Last Post: 08-17-2011, 04:53 PM
  3. Opening links in new window
    By maebeeso in forum Flash
    Replies: 5
    Last Post: 05-30-2008, 01:00 AM
  4. Using HV Menu and Opening Links in New Window
    By bjrenton in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 11-29-2005, 07:38 PM
  5. Opening Links In Same Window
    By Regular in forum HTML
    Replies: 1
    Last Post: 07-20-2005, 11:24 AM

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
  •