我有一個鏈接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