所以,我基本上试图根据当前的URL显示特定的RSS提要。我在某处有以下解决方案,但我不想在变量中指定网址,而是检查当前网址并if it contains
然后执行/拉取我的RSS Feed。
以下解决方案无法正常工作,因为我需要对多个URL进行多次检查。
jQuery(function($) { // display rss feed based on current URL
// start conditions to display 3 feeds on different URLs
var url = 'http://localhost:8888/';
if (url.indexOf('8888') > -1) {
$(".feed1").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed2").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed3").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
}
if (url.indexOf('movies') > -1) {
$(".feed1").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed2").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed3").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
}
.......
请注意,Feed网址会有所不同。这只是一个样本。
答案 0 :(得分:1)
而不是
var url = 'http://localhost:8888/';
做
var url = window.location.href;