Results 1 to 3 of 3

Thread: Open offsite links problem in FF

  1. #1
    Join Date
    Dec 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face Open offsite links problem in FF

    1) Script Title:
    Open offsite links in new window
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...newwindow2.htm

    3) Describe problem:

    I have just today launched a site using this script. Straighforward external links work fine, but one link is more complex. It has - a string? (sorry, don't know correct jargon). Firefox opens this link in the same tab. No problem on IE!

    I tried the solution posted near the end of the 12-03-07 Thread - offsite links in new window script, which appears to discuss the same problem, but it didn't change things and an earlier post in the same thread said the original script worked to open a new window in FF so I am sticking with the original and wondering if I have something else wrong. My problem page url is http://www.lifechch.org.nz/community.html - link in question is just a little way down on the word 'more...' Thanks for any help!

  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

    I know it looks like that is the problem, but I've seen this before, it is actually your named anchors:

    HTML Code:
    <a name="com_care">
    and:

    HTML Code:
    <a name="kpa">
    which just happen to be the a tags immediately preceding the one with query string, which just happens to be the last one on the page that you would want to be opening offsite. To fix that, edit the script, adding the red part into the function as indicated below:

    Code:
    assigntarget:function(){
    	var rexcludedomains=new RegExp(this.excludedomains.join("|"), "i")
    	var all_links=document.getElementsByTagName("a")
    	if (this.mode=="auto" || (this.mode=="manual" && this.togglebox.checked)){
    		for (var i=0; i<=(all_links.length-1); i++){
    			if (all_links[i].href && all_links[i].hostname.search(rexcludedomains)==-1 && all_links[i].href.indexOf("http:")!=-1)
    				all_links[i].target=ddwindowlinks.linktarget
    		}
    	}
    	else{
    		for (var i=0; i<=(all_links.length-1); i++)
    			all_links[i].target=""
    	}
    	if (this.mode=="manual" && this.persist)
    		this.setCookie("dlinktarget", (this.togglebox.checked)? "yes" : "no", 30) //remember user setting for 30 days (set to -1 then reload page to erase cookie)
    },
    - John
    ________________________

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

  3. #3
    Join Date
    Dec 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb

    Yes, that is what was on the other post. I tried it and it didn't work, BUT I decided to try again only to notice I had unticked the little box to open a new window - no wonder it didn't work! It does now!! Sorry about that! However, at the moment I am at a computer with IE7 (I have IE6 and FF). This IE7 opens a new window rather than a new tab. Any way round this?
    Last edited by keentolearn; 12-11-2007 at 08:51 PM. Reason: Tried on IE7

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
  •