View Single Post
  #6 (permalink)  
Old Dec 9th, 2007, 20:53
Stuart Stuart is offline
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: For all Javascript Coding Experts, can you break down this code?

Let me explain. The code you posted in your first post above "creates" a script. The source is a very long URL. When you go to that URL, you get this:
Code: Select all
function homeLink (locid){ window.location = 'http://wowweb.weather.com/weather/local/'+locid; } var intImage = 2; var tabs = new Array();tabs[tabs.length] = 'tab1';tabs[tabs.length] = 'tab2'; function selectTab(tab) {for( index = 0; index < tabs.length; index++ ) { var img = document.getElementById(tabs[index]); if( (index + 1) == tab ) { img.src = img.src.replace('Off', 'On'); } else { img.src = img.src.replace('On', 'Off'); } if(tab==1) { document.getElementById('tab4').style.border="#333333 solid"; document.getElementById('tab4').style.borderWidth="0px 0px 1px 0px"; document.getElementById('tab3').style.border="#CCCCCC solid"; document.getElementById('tab3').style.borderWidth="0px 0px 1px 0px"; if (document.getElementById) document.getElementById('maptab1').style.display = "block"; if (document.getElementById) document.getElementById('maptab2').style.display = "none"; } else if(tab==2) { document.getElementById('tab4').style.border="#CCCCCC solid"; document.getElementById('tab4').style.borderWidth="0px 0px 1px 0px"; document.getElementById('tab3').style.border="#333333 solid"; document.getElementById('tab3').style.borderWidth="0px 0px 1px 0px"; if (document.getElementById) document.getElementById('maptab2').style.display = "block"; if (document.getElementById) document.getElementById('maptab1').style.display = "none"; }}} function doSearch(){ var wh = document.getElementById('zipcode').value; window.open("http://wowweb.weather.com/search/enhanced?what=Weather36HourBusinessTravelerCommand&config=SZ=300x250*WX=FHW*LNK=SSNL*UNT=F*BGI=winter*MAP=null|null*DN=rimnordic.com*TIER=0*PID=1053527172*MD5=ea755d53ba19a108ceb4fc74b920d6e2&par=WOWs0_1053527172&site=300x250&cm_ven=WOWs0&cm_cat=300x250&code=link&promo=searchbox&cm_ite=link&cm_pla=searchbox&where="+wh, "wownewwin"); return false;} function hrefURL (url){ window.location = url; } if (document.getElementById && !document.getElementById('wx_wow_css') ) { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.id = 'wx_wow_css'; link.rel = 'stylesheet'; link.type = 'text/css'; link.title = 'wow'; // replace the next line with conditional code based on protocol link.href = 'http://imawow.weather.com/web/common/header/stylesheet/wow.css'; head.appendChild(link); } function addEvent(objObject, strEventName, fnHandler) { if (objObject.addEventListener) objObject.addEventListener(strEventName, fnHandler, false); else if (objObject.attachEvent) objObject.attachEvent("on" + strEventName, fnHandler); } function initIE(divId, moduleHTML) { var newDiv = document.createElement('div'); newDiv.innerHTML = moduleHTML; var loadingDiv = newDiv.firstChild.cloneNode(false); loadingDiv.innerHTML = 'Loading...

';                  var targetDiv = document.getElementById(divId);         targetDiv.innerHTML = '';         targetDiv.appendChild(loadingDiv);                  addEvent(window, 'load',                 function() {  		targetDiv.className = "wow_container";                 targetDiv.innerHTML = newDiv.innerHTML;                }         );  }       function init(divId, moduleHTML) {        if (document.all) {                initIE(divId, moduleHTML)         } else { 	      document.getElementById(divId).className =  "wow_container";               document.getElementById(divId).innerHTML = moduleHTML;         }  } init('wx_module_9429',''+ '   '+ ''+ ' '+ '  '+ ' '+ ' '+ 'Your local forecast
available at weather.com'+ '
');
Now you can modify this code to achieve what you wanted...

If you need any help with modifying the script, just ask
Reply With Quote