![]() |
|
|||||||
| JavaScript Programming Discuss javascript coding. |
| Have A Look At Some Of Our Webmaster Related Sponsors! | |||||
![]() Script Directory |
![]() Shopping Cart |
![]() Market Leverage |
![]() Free Templates |
![]() 3D Guide-characters |
![]() Advertise Here |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
New Hunter
|
Hi everyone,
I've been searching everywhere for an answer, but have yet to find one. My problem is this: I'm drawing news feeds dynamically on a client's site using iframes. The feeds come through as a definition list (dl), with the article titles as dt's, and their source as dd's. I've been able to alter the appearance of the list in a way that resembles a table, using the following: PHP Code:
Here is how the list is coming through: PHP Code:
|
|
|
|
|
|
#2 (permalink) |
|
New Hunter
|
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]);
}
}
}
};
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|