View Single Post
Old 01-14-2008, 12:37 PM   #2 (permalink)
Toicantien
New Hunter
 

Join Date: Jan 2008
Posts: 14
iTrader: 0 / 0%
Hunter Bux: 0
Toicantien is on a distinguished road
Default

You say you're loading this RSS feed in a client's site using an IFRAME? Is the client's page trying to access the IFRAME page using JavaScript, or is this RSS feed appearing wholly in the IFRAME and you just want a script that automatically parses the IFRAME for the RSS feed? If so, the following code should help out:
Code:
function alternateRows(el) {
  var i = 0;
  var end = 0;
  
  // Check for browser compatibility
  if (!document.getElementById || !document.getElementsByTagName) return;
  
  if (typeof(el) == "string") {
    el = document.getElementById(el);
  }
  
  switch (el.nodeName) {
    
    case "TABLE":
      for (i, end = el.rows.length; i < end; i++) {
        el.rows[i].className += i%2==0 ? "rowA" : "rowB";
      }
      break;
    
    case "DL":
      var dds = el.getElementsByTagName("dd");
      var dts = el.getElementsByTagName("dt");
      var className = "";
      
      for (i, end = dts.length; i < end; i++) {
        className = i%2==0 ? "rowA" : "rowB";
        dds[i].className += className;
        dts[i].className += className;
      }
      break;
    
  } 
}


window.onload = function() {
  if (document.getElementsByTagName) {
    var dls = document.getElementsByTagName("dl");
    var i = 0;
    var end = dls.length;
    
    for (i; i < end; i++) {
      if (dls[i].className.indexOf("i_rss") > -1) {
        alternateRows(dls[i]);
      }
    }
  }
};
You would place that code in the HEAD of the IFRAME HTML document. If this doesn't work, can you post more specifically how this RSS feed is being put on the client's page? This script will support both TABLEs and DLs.
Toicantien is offline   Reply With Quote