Sounds like a layout/style issue. I used absolute positioning to enable the script to switch the feeds. The container they are in is relatively positioned -
From the stylesheet of my demo:
Code:
#feeds {
position: relative;
}
and its markup:
Code:
<div id="feeds">
<input type="button" onclick="togFeeds();" value="Toggle Feeds">
<!-- <h3>Example 1: (Single RSS feed, 10 entries, "<code>date</code>" field enabled, 1 entry per page</h3> -->
<div id="feed">CSS:</div>
<script type="text/javascript">
var cssfeed=new gfeedrssticker("CSS", "example1class", 2000, "_new")
cssfeed.addFeed(" . . .
[SNIP!]
. . . ://rss.news.yahoo.com/rss/topstories") //Specify "label" plus URL to RSS feed
newsfeed.displayoptions("datetime snippet") //show the specified additional fields
newsfeed.setentrycontainer("p") //Display each entry as a paragraph
newsfeed.filterfeed(8, "date") //Show 8 entries, sort by date
newsfeed.entries_per_page(2)
newsfeed.init() //Always call this last
</script>
</div>
But it has no height. If you give it a height as high as the tallest feed, say:
Code:
#feeds {
position: relative;
height: 300px;
}
- whatever works out for you, that will probably take care of it.
Or you might want to use this modified version, it adjust to the height of any given feed:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAdqvl6yCCl39fDLKK9GVwzxTlGbvVmibuY2kVQYy3kV9f1ueOCBRdbSAKQw824dFLL7Hj_4D_vHuNOA"></script>
<script type="text/javascript" src="gfeedfetcher.js"></script>
<script type="text/javascript" src="gajaxticker.js">
/***********************************************
* gAjax RSS Ticker- (c) Dynamic Drive (www.dynamicdrive.com)
* Requires "gfeedfetcher.js" class
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<style type="text/css">
.titlefield{ /*CSS for RSS title link in general*/
text-decoration: none;
}
.labelfield{ /*CSS for label field in general*/
color:brown;
font-size: 90%;
}
.datefield{ /*CSS for date field in general*/
color:gray;
font-size: 90%;
}
#CSS{ /*Demo 1 main container*/
width: 450px;
height: 28px;
border: 1px solid black;
padding: 4px;
background-color: lightyellow;
}
#Social{ /*Demo 2 main container*/
width: 600px;
height: 180px;
border: 1px dashed black;
padding: 4px;
background-color: #EEEEEE;
visibility: hidden;
position: absolute;
}
#Social ul{ /*Demo 2 UL container*/
margin: 0;
padding-left: 18px;
}
#Social ul li{ /*Demo 2 LI that surrounds each entry*/
margin-bottom: 4px;
}
#News{ /*Demo 3 main container*/
width: 250px;
height: 280px;
border: 1px solid navy;
padding: 4px;
visibility: hidden;
position: absolute;
}
#News p{ /*Demo 3 P element that separates each entry*/
margin-top: 0;
margin-bottom: 7px;
}
code{ /*CSS for insructions*/
color: red;
}
#feeds {
position: relative;
}
</style>
<script type="text/javascript">
function togFeeds(){
var feeds = [cssfeed, socialfeed, newsfeed];
for (var i = feeds.length - 1; i > -1; --i){
feeds[i].tickerdiv.style.visibility = i === togFeeds.num? 'visible' : 'hidden';
feeds[i].tickerdiv.style.position = i === togFeeds.num? 'static' : 'absolute';
}
document.getElementById('feed').innerHTML = feeds[togFeeds.num].tickerid + ':'
togFeeds.num = (togFeeds.num + 1) % feeds.length;
}
togFeeds.num = 1;
</script>
</head>
<body>
Some content before
<div id="feeds">
<input type="button" onclick="togFeeds();" value="Toggle Feeds">
<!-- <h3>Example 1: (Single RSS feed, 10 entries, "<code>date</code>" field enabled, 1 entry per page</h3> -->
<div id="feed">CSS:</div>
<script type="text/javascript">
var cssfeed=new gfeedrssticker("CSS", "example1class", 2000, "_new")
cssfeed.addFeed("CSS Drive", "http://www.cssdrive.com/index.php/news/rss_2.0/") //Specify "label" plus URL to RSS feed
cssfeed.displayoptions("date") //show the specified additional fields
cssfeed.setentrycontainer("div") //Wrap each entry with a DIV tag
cssfeed.filterfeed(10, "date") //Show 10 entries, sort by date
cssfeed.entries_per_page(1)
cssfeed.init()
</script>
<!-- <h3>Example 2: (Two RSS feeds, 20 entries, "<code>label"</code>, "<code>datetime</code>", and "<code>snippet</code>" fields enabled, 5 entries per page</h3> -->
<script type="text/javascript">
var socialfeed=new gfeedrssticker("Social", "example2class", 3000, "")
socialfeed.addFeed("Slashdot", "http://rss.slashdot.org/Slashdot/slashdot") //Specify "label" plus URL to RSS feed
socialfeed.addFeed("Digg", "http://digg.com/rss/index.xml") //Specify "label" plus URL to RSS feed
socialfeed.displayoptions("label datetime") //show the specified additional fields
socialfeed.setentrycontainer("li") //Display each entry as a DIV
socialfeed.filterfeed(20, "label") //Show 15 entries, sort by label
socialfeed.entries_per_page(5)
socialfeed.init() //Always call this last
</script>
<!-- <h3>Example 3: (Three RSS feeds, 8 entries, "<code>datetime</code>" and "<code>snippet</code>" fields enabled, 2 entries per page</h3> -->
<script type="text/javascript">
var newsfeed=new gfeedrssticker("News", "example3class", 2500, "_new")
newsfeed.addFeed("BBC", "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml") //Specify "label" plus URL to RSS feed
newsfeed.addFeed("MSNBC", "http://www.msnbc.msn.com/id/3032091/device/rss/rss.xml") //Specify "label" plus URL to RSS feed
newsfeed.addFeed("Yahoo News", "http://rss.news.yahoo.com/rss/topstories") //Specify "label" plus URL to RSS feed
newsfeed.displayoptions("datetime snippet") //show the specified additional fields
newsfeed.setentrycontainer("p") //Display each entry as a paragraph
newsfeed.filterfeed(8, "date") //Show 8 entries, sort by date
newsfeed.entries_per_page(2)
newsfeed.init() //Always call this last
</script>
</div>
Other content after
</body>
</html>
In either case, other styles/layout of you page may require yet another approach.
If you want more help:
Please post a link to a page on your site that contains the problematic code so we can check it out.
Bookmarks