我有一个链接href为"/news#1930"
。当我在/news
页面上点击此链接时,它不会刷新页面(它只会将#1930添加到URL的末尾)。我希望它刷新页面虽然(我使用#标签后的信息与一些jquery加载相应的iframe中的特定文章,当它不刷新它不会加载新的文章)。有关如何强制刷新的任何想法?如何使用哈希标签制作页面Href刷新
我目前的代码是:
$(document).ready(function() {
var $news_story = $(window.location.hash.substring(1)),
$news_number = $news_story.selector,
$news_url = 'http://www.synergy-pr.com/news/mediacenter/index.html?view=article&CustomerID=41b1if9-a17d4va5sf7of15e3kb0pa3kd2y-99d03n8sq4ad2xk8h47j00r98el5pf&ClientArticleID=' + $news_number, //url of specific article
$news_url_default = 'http://www.synergy-pr.com/news/mediacenter/index.html?CustomerID=41b1if9-a1hd4xa52f78f1ke3bb0oa3ld2k-90208c8g64x02nh8wf7ad0m181p5su'; //url of general news page
if ($news_number.length>0) { //if their is a # with a number, this means it is a sidebar link and should load that specific article
$('#news-feed').attr('src', $news_url);
} else { //if not, load the main news page
$('#news-feed').attr('src', $news_url_default);
}
});
好,良好的通话。这适用于一个链接,但我实际上有三个这样的链接。当它们都有空格时,就会出现不刷新的问题。我在第一个,第二个和第三个之间放了一个空格,从而绕开了这个问题。这有效,但不能成为最好的方式。有关如何使这一点变得更好的想法? – Andrew 2010-11-12 21:43:14
没有太多的哈希URL。我不认为有另一条路线。也许标记散列值将是使用多个散列值的好替代。 – 2010-11-14 01:31:07