【发布时间】:2011-05-09 07:34:57
【问题描述】:
我有一个链接,其 href 为 "/news#1930"。当我在/news 页面上单击此链接时,它不会刷新页面(它只是将#1930 添加到 URL 的末尾)。我希望它刷新页面(我使用 # 标记后的信息和一些 jquery 将特定文章加载到相应的 iframe 中,当它不刷新时不会加载新文章)。关于如何强制刷新的任何想法?
我目前的代码是:
$(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);
}
});
【问题讨论】:
标签: jquery iframe hyperlink href