Jump to content

2 JavaScript functions won't work together


mboehler3

Recommended Posts

Hi, I would like to start off my saying I know little about JavaScript, usually enough to get me by. However I'm stuck with loading two JavaScript's on my page.Both of the scripts below work on their own. However when I call them both on the same page, only one of these work. Can someone possibly look at this code and lend some advice?Here are both of the scripts:

<script type="text/javascript">		function tbox() {			tb_show("Easy and Affordable Service", "/interstitial.asp?KeepThis=true&TB_iframe=true&height=400&width=600", "");		}		window.onload = function() {			window.setTimeout(tbox, 10000);		}	</script>

and

function tabberObj(_1){var _2;this.div=null;this.classMain="tabber";this.classMainLive="tabberlive";this.classTab="tabbertab";this.classTabDefault="tabbertabdefault";this.classNav="tabbernav";this.classTabHide="tabbertabhide";this.classNavActive="tabberactive";this.titleElements=["h2","h3","h4","h5","h6"];this.titleElementsStripHTML=true;this.removeTitle=true;this.addLinkId=false;this.linkIdFormat="<tabberid>nav<tabnumberone>";for(_2 in _1){this[_2]=_1[_2];}this.REclassMain=new RegExp("\\b"+this.classMain+"\\b","gi");this.REclassMainLive=new RegExp("\\b"+this.classMainLive+"\\b","gi");this.REclassTab=new RegExp("\\b"+this.classTab+"\\b","gi");this.REclassTabDefault=new RegExp("\\b"+this.classTabDefault+"\\b","gi");this.REclassTabHide=new RegExp("\\b"+this.classTabHide+"\\b","gi");this.tabs=new Array();if(this.div){this.init(this.div);this.div=null;}};tabberObj.prototype.init=function(e){var _3,i,i2,t,_4=0,_5,_6,_7,_8,_9;if(!document.getElementsByTagName){return false;}if(e.id){this.id=e.id;}this.tabs.length=0;_3=e.childNodes;for(i=0;i<_3.length;i++){if(_3[i].className&&_3[i].className.match(this.REclassTab)){t=new Object();t.div=_3[i];this.tabs[this.tabs.length]=t;if(_3[i].className.match(this.REclassTabDefault)){_4=this.tabs.length-1;}}}_5=document.createElement("ul");_5.className=this.classNav;for(i=0;i<this.tabs.length;i++){t=this.tabs[i];t.headingText=t.div.title;if(this.removeTitle){t.div.title="";}if(!t.headingText){for(i2=0;i2<this.titleElements.length;i2++){_9=t.div.getElementsByTagName(this.titleElements[i2])[0];if(_9){t.headingText=_9.innerHTML;if(this.titleElementsStripHTML){t.headingText.replace(/<br>/gi," ");t.headingText=t.headingText.replace(/<[^>]+>/g,"");}break;}}}if(!t.headingText){t.headingText=i+1;}_6=document.createElement("li");t.li=_6;_7=document.createElement("a");_7.appendChild(document.createTextNode(t.headingText));_7.href="java script:void(null);";_7.title=t.headingText;_7.onclick=this.navClick;_7.tabber=this;_7.tabberIndex=i;if(this.addLinkId&&this.linkIdFormat){_8=this.linkIdFormat;_8=_8.replace(/<tabberid>/gi,this.id);_8=_8.replace(/<tabnumberzero>/gi,i);_8=_8.replace(/<tabnumberone>/gi,i+1);_8=_8.replace(/<tabtitle>/gi,t.headingText.replace(/[^a-zA-Z0-9\-]/gi,""));_7.id=_8;}_6.appendChild(_7);_5.appendChild(_6);}e.insertBefore(_5,e.firstChild);e.className=e.className.replace(this.REclassMain,this.classMainLive);this.tabShow(_4);if(typeof this.onLoad=="function"){this.onLoad({tabber:this});}return this;};tabberObj.prototype.navClick=function(_a){var _b,a,_c,_d,_e;a=this;if(!a.tabber){return false;}_c=a.tabber;_d=a.tabberIndex;a.blur();if(typeof _c.onClick=="function"){_e={"tabber":_c,"index":_d,"event":_a};if(!_a){_e.event=window.event;}_b=_c.onClick(_e);if(_b===false){return false;}}_c.tabShow(_d);return false;};tabberObj.prototype.tabHideAll=function(){var i;for(i=0;i<this.tabs.length;i++){this.tabHide(i);}};tabberObj.prototype.tabHide=function(_f){var div;if(!this.tabs[_f]){return false;}div=this.tabs[_f].div;if(!div.className.match(this.REclassTabHide)){div.className+=" "+this.classTabHide;}this.navClearActive(_f);return this;};tabberObj.prototype.tabShow=function(_10){var div;if(!this.tabs[_10]){return false;}this.tabHideAll();div=this.tabs[_10].div;div.className=div.className.replace(this.REclassTabHide,"");this.navSetActive(_10);if(typeof this.onTabDisplay=="function"){this.onTabDisplay({"tabber":this,"index":_10});}return this;};tabberObj.prototype.navSetActive=function(_11){this.tabs[_11].li.className=this.classNavActive;return this;};tabberObj.prototype.navClearActive=function(_12){this.tabs[_12].li.className="";return this;};function tabberAutomatic(_13){var _14,_15,i;if(!_13){_13={};}_14=new tabberObj(_13);_15=document.getElementsByTagName("div");for(i=0;i<_15.length;i++){if(_15[i].className&&_15[i].className.match(_14.REclassMain)){_13.div=_15[i];_15[i].tabber=new tabberObj(_13);}}return this;};function tabberAutomaticOnLoad(_16){var _17;if(!_16){_16={};}_17=window.onload;if(typeof window.onload!="function"){window.onload=function(){tabberAutomatic(_16);};}else{window.onload=function(){_17();tabberAutomatic(_16);};}};if(typeof tabberOptions=="undefined"){tabberAutomaticOnLoad();}else{if(!tabberOptions["manualStartup"]){tabberAutomaticOnLoad(tabberOptions);}}

Thank you in advance for any help you can provide!

Link to comment
Share on other sites

Yeesh, who wrote that tabber script? Someone thought it was a good idea to use numeric and single-letter variable names for everything.Notice how the tabber script checks if window.onload is already defined and either adds to it or defines it:

_17=window.onload;if(typeof window.onload!="function"){  window.onload=function(){	tabberAutomatic(_16);  };}else{  window.onload=function(){	_17();	tabberAutomatic(_16);  };}

The other script should do something similar. Right now it just sets window.onload to whatever it wants, so it's going to overwrite whatever was already there.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...