PDA

View Full Version : Open offsite links problem in FF



keentolearn
12-11-2007, 06:38 AM
1) Script Title:
Open offsite links in new window
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex8/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!

jscheuer1
12-11-2007, 06:53 AM
I know it looks like that is the problem, but I've seen this before, it is actually your named anchors:


<a name="com_care">

and:


<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:


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)
},

keentolearn
12-11-2007, 09:11 AM
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?