N
Neo Geshel
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.getElementsByTagName) return;
var a = document.getElementsByTagName('a');
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") >= 0) && (agt.indexOf("opera") == -1));
for (var i=0; i<a.length; i++){
if ((is_ie) && (a.getAttribute('href') != null) &&
(a.getAttribute('href').indexOf("://") >= 0) &&
(a.getAttribute('rel') == "external") &&
(a.getAttribute('href').indexOf("/check/referer") >= 0)){
a.target = '_blank';
a.title += ' (opens in new window)';
}
else if ((a.getAttribute('href') != null) &&
(a.getAttribute('href').indexOf("://") >= 0) &&
(a.getAttribute('rel') == "external")) {
a.title += ' (opens in new window)';
a.onclick = openWin;
a.onkeypress = openWin;
}
}
}
function openWin() {
var url = this.href;
var target = '_blank';
var options = 'top=' + (screen.availHeight/2-250) + ',left=' +
(screen.availWidth/2-400) +
',outerwidth=800,outerheight=500,menubar=no,toolbar=no,locationbar=no,personalbar=no,directories=no,statusbar=no,scrollbars=yes,resizable=yes';
window.open(url,target,options);
return false;
}
window.onload = popWin;
<!--end popupwin.js-->
<!--start toggle.js-->
function toggleNext(el,tname,first) {
var next=el.nextSibling;
var tags=el.parentNode.getElementsByTagName(tname);
while(next.nodeType != 1) next = next.nextSibling;
next.style.display=((next.style.display=="none") ? "block" : "none");
if (first!=1){
for (i=0; i<tags.length; i++) {
var tohide=tags.nextSibling;
while(tohide.nodeType != 1) tohide = tohide.nextSibling;
if (tohide!=next){tohide.style.display="none";}
}
}
}
function toggleNextByIdAndTag() {
var ccn="focus";
clickers=document.getElementById("toggle").getElementsByTagName("dt");
for (i=0; i<clickers.length; i++) {
clickers.className+=" "+ccn;
clickers.onclick=function() {toggleNext(this,"dt")}
toggleNext(clickers,"dt",1);
}
}
window.onload=toggleNextByIdAndTag;
<!--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.
*********************************************************************
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.getElementsByTagName) return;
var a = document.getElementsByTagName('a');
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") >= 0) && (agt.indexOf("opera") == -1));
for (var i=0; i<a.length; i++){
if ((is_ie) && (a.getAttribute('href') != null) &&
(a.getAttribute('href').indexOf("://") >= 0) &&
(a.getAttribute('rel') == "external") &&
(a.getAttribute('href').indexOf("/check/referer") >= 0)){
a.target = '_blank';
a.title += ' (opens in new window)';
}
else if ((a.getAttribute('href') != null) &&
(a.getAttribute('href').indexOf("://") >= 0) &&
(a.getAttribute('rel') == "external")) {
a.title += ' (opens in new window)';
a.onclick = openWin;
a.onkeypress = openWin;
}
}
}
function openWin() {
var url = this.href;
var target = '_blank';
var options = 'top=' + (screen.availHeight/2-250) + ',left=' +
(screen.availWidth/2-400) +
',outerwidth=800,outerheight=500,menubar=no,toolbar=no,locationbar=no,personalbar=no,directories=no,statusbar=no,scrollbars=yes,resizable=yes';
window.open(url,target,options);
return false;
}
window.onload = popWin;
<!--end popupwin.js-->
<!--start toggle.js-->
function toggleNext(el,tname,first) {
var next=el.nextSibling;
var tags=el.parentNode.getElementsByTagName(tname);
while(next.nodeType != 1) next = next.nextSibling;
next.style.display=((next.style.display=="none") ? "block" : "none");
if (first!=1){
for (i=0; i<tags.length; i++) {
var tohide=tags.nextSibling;
while(tohide.nodeType != 1) tohide = tohide.nextSibling;
if (tohide!=next){tohide.style.display="none";}
}
}
}
function toggleNextByIdAndTag() {
var ccn="focus";
clickers=document.getElementById("toggle").getElementsByTagName("dt");
for (i=0; i<clickers.length; i++) {
clickers.className+=" "+ccn;
clickers.onclick=function() {toggleNext(this,"dt")}
toggleNext(clickers,"dt",1);
}
}
window.onload=toggleNextByIdAndTag;
<!--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.
*********************************************************************