I am experiencing a collision between two scripts, but I cannot find
where it is. I am hoping that someone here can help me.
I have two external JS files that I call into each web page. One
provides me with a standards-compliant way of creating pop-up windows by
simply adding a rel="external" to each anchor. The other allows me to
have toggled definition lists.
When the popupwin.js file is by itself, all anchors with rel="external"
and an external address (http://...) work just fine, spawning windows
just as required. When I add the toggle.js file, it works properly, but
causes the popupwin.js file to stop working completely. Why? How can I
correct this?
Below are the two files:
<!--start popupwin.js -->
function popWin(){
if (!document.getE lementsByTagNam e) return;
var a = document.getEle mentsByTagName( 'a');
var agt = navigator.userA gent.toLowerCas e();
var is_ie = ((agt.indexOf(" msie") >= 0) && (agt.indexOf("o pera") == -1));
for (var i=0; i<a.length; i++){
if ((is_ie) && (a[i].getAttribute(' href') != null) &&
(a[i].getAttribute(' href').indexOf( "://") >= 0) &&
(a[i].getAttribute(' rel') == "external") &&
(a[i].getAttribute(' href').indexOf( "/check/referer") >= 0)){
a[i].target = '_blank';
a[i].title += ' (opens in new window)';
}
else if ((a[i].getAttribute(' href') != null) &&
(a[i].getAttribute(' href').indexOf( "://") >= 0) &&
(a[i].getAttribute(' rel') == "external") ) {
a[i].title += ' (opens in new window)';
a[i].onclick = openWin;
a[i].onkeypress = openWin;
}
}
}
function openWin() {
var url = this.href;
var target = '_blank';
var options = 'top=' + (screen.availHe ight/2-250) + ',left=' +
(screen.availWi dth/2-400) +
',outerwidth=80 0,outerheight=5 00,menubar=no,t oolbar=no,locat ionbar=no,perso nalbar=no,direc tories=no,statu sbar=no,scrollb ars=yes,resizab le=yes';
window.open(url ,target,options );
return false;
}
window.onload = popWin;
<!--end popupwin.js-->
<!--start toggle.js-->
function toggleNext(el,t name,first) {
var next=el.nextSib ling;
var tags=el.parentN ode.getElements ByTagName(tname );
while(next.node Type != 1) next = next.nextSiblin g;
next.style.disp lay=((next.styl e.display=="non e") ? "block" : "none");
if (first!=1){
for (i=0; i<tags.length; i++) {
var tohide=tags[i].nextSibling;
while(tohide.no deType != 1) tohide = tohide.nextSibl ing;
if (tohide!=next){ tohide.style.di splay="none";}
}
}
}
function toggleNextByIdA ndTag() {
var ccn="focus";
clickers=docume nt.getElementBy Id("toggle").ge tElementsByTagN ame("dt");
for (i=0; i<clickers.leng th; i++) {
clickers[i].className+=" "+ccn;
clickers[i].onclick=functi on() {toggleNext(thi s,"dt")}
toggleNext(clic kers[i],"dt",1);
}
}
window.onload=t oggleNextByIdAn dTag;
<!--end toggle.js-->
Thanks for any help.
....Geshel
--
*************** *************** *************** *************** *********
My e-mail address is an automatically monitored spam honeypot. Do not
send e-mail there unless you wish to be reported as a spammer. Please
send any e-mail to my first name at my last name dot org.
*************** *************** *************** *************** *********