【发布时间】:2011-07-09 20:52:31
【问题描述】:
我一直在尝试让 Jquery 地址插件正常工作大约 12 个小时,因此我认为是时候发布了。我遇到的问题是后退和前进导航不起作用。 IE:点击一个链接然后点击后退按钮实际上并没有导航回来。它虽然改变了网址。让我相信我做错了什么的另一件事是我插入了$.address.title($(this).attr("title"));,它实际上并没有改变地址。
这里是jquery:
$('#swNavlist a').address();
$('#swNavlist a').click(function() {
$("#swBody").block({
message:"Loading",
css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
} });
var content_show = $(this).attr("href").replace(/^#/, '');
$.ajax({
method: "get",url: content_show,
//"+bvLanguage+"/
success: function(html){ //so, if data is retrieved, store it in html
$("#swBody").html(html); //show the html inside .content div
$("#swBody").unblock();
$.address.title($(this).attr("title"));
},//success
error: function(){
$("#swBody").unblock();
$("#swBody").block({
message:"Error Encountered",
css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
},
timeout:1000
})
}
}); //close $.ajax(
$("#swNavlist").topZIndex();
});//end navigation
此处为 HTML:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<Title>Swebits Home</title>
<link href="css/swCss.css" rel="styleSheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.pngFix.js"></script>
<script type="text/javascript" src="js/jquery.blockUI.js"></script>
<script type="text/javascript" src="js/jquery.topzindex.min.js"></script>
<script type="text/javascript" src="js/sw.js"></script>
<script type="text/javascript" src="js/jquery.address-1.3.2.min.js?autoUpdate=1"></script>
</head>
<body>
<div id="swHead">
<div class="leftCol"></div>
<div class="centerCol">
<div class="navigation">
<ul id="swNavlist">
<li id="active"><a href="#home.html" id="current" title="Swebits Home">Home</a></li>
<li><a href="#webd.html" title="Swebits Web Development">Web Design</a></li>
<li><a href="#bla.html" title="webs.html">Web Systems</a></li>
<li><a href="" title="hosting.html">Hosting</a></li>
<li><a href="" title="photo.html">Photography</a></li>
<li><a href="" title="portfolio.html">Portfolio</a></li>
<li><a href="" title="network.html">Our Network</a></li>
<li><a href="" title="contact.html">Contact</a></li>
</ul>
</div>
</div>
<div class="rightCol"></div>
</div>
<div id="swContainer" class="clearfix">
<div id="swCenter" class="clearfix">
<div id="swBody">
<?php
include("home.html");
?>
</div>
<div id="swFooter">
</div>
</div>
</div>
</body>
最后,我尝试实现一个 if 语句,以便如果目标为空白,页面将重定向到“error.html”,但这似乎也不起作用。
感谢您的帮助!
【问题讨论】:
-
我时间紧迫,可能误解了你在做什么,所以我不会发布这个作为答案。如果我正确理解您的目标,我相信您使用的绝对最佳插件是benalman.com/projects/jquery-bbq-plugin
标签: jquery url-rewriting navigation history jquery-address