Keyword
Please note that official support for commercial extensions & templates is provided in the Subscriber Help Desk.
Support requests should ONLY be directed there and require an active subscription plan.
This forum board is to be used for archive purposes and knowledge exchange ONLY.

JavaScript Conflict - I know where, but need help fixing it!

  • tlm2021
  • tlm2021's Avatar Topic Author
  • Offline
  • New Member
More
15 years 4 months ago #26027 by tlm2021
So I have a conflict, and I know where it is. But I don't know how to resolve it without breaking the script. I had this in the free forum on accident. I am a pro user. I'm using the HighSlide pop-up engine, but have seen the conflict on multiple engines.

The site we're having issues on is www.hitchcarriers.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=21&category_id=1&option=com_virtuemart&Itemid=1 .

Here's the conflicting code:
//Script for tabbed boxes on the product pages
	function hidestories() {
	var divs=document.getElementById('stories').getElementsByTagName('div');
	for (j=0; j<divs.length; j++) {
		var rE = new RegExp("(^|\\s)" + 'story' + "(\\s|$)");
		if (rE.test(divs[j].className)) {
			divs[j].style.display="none";
		}
	}
}

function stories(first) {
	var thebuttons=document.getElementById('thebuttons').getElementsByTagName('a');
	for (i=0; i<thebuttons.length; i++) {
		thebuttons[i].onclick=function() {
			hidestories();
			var thestory=(this.href).split("#",2)[1];
			document.getElementById(thestory).style.display="block";
			var active=document.getElementById('activeTab');
			active.id="";
			this.parentNode.id="activeTab";
			return false;
		}
	}

	if (first) {
		var firstone=document.getElementById('stories').firstChild;
		if (firstone.nodeType != 1) {firstone = firstone.nextSibling;}
		firstone.style.display="block";
		
		var firstlink=document.getElementById('thebuttons').firstChild;
		if (firstlink.nodeType != 1) {firstlink = firstlink.nextSibling;}
		firstlink.id="activeTab";
	}
}

window.onload=function() {
	if (document.getElementById('thebuttons')){	
		hidestories();
		stories(1);
	}
}

I can resolve the conflict by commenting out any of the following lines:
for (i=0; i<thebuttons.length; i++) {
thebuttons[i].onclick=function() {
if (first) {

If I comment out the for loop, or if statement, the conflict is resolved. But if I comment everything within the for loop or if statement, it isn't. So somehow the if statement and for loop themselves are causing the conflict. I just don't know how.

Any help would be greatly appreciated.

Please Log in or Create an account to join the conversation.

  • tlm2021
  • tlm2021's Avatar Topic Author
  • Offline
  • New Member
More
15 years 4 months ago #26028 by tlm2021
Anybody? I'm a pro user, and would like some form of support. Even a reply saying more information is needed or anything to at least let me know this got read.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum