利用下班的时候研究了一下鑫鑫大虾的jquery实现返回顶部的滑动效果的文章,目的是想把网站底部的那“返回顶部”几个字的JS效果搞好一点。
于是乎,网页状态栏出现了个大大的感叹号且Light Box不能正常工作了!卸掉LB,对照着Amy选择Mr. Right的标准,驱狗搜索,找到:给文章中图片自动加lightbox效果,没有效果?难道是有冲突?重新检查header.php,去掉了无关的LB style,再次以失败告终。
最后发现,只有在<body></body>中加入jquery实现返回顶部的滑动效果文章中的jquery代码时,文章出现上述LB无效果和出现错误的提示问题。
<script type=”text/javascript”>
$(document).ready(function() {
function filterPath(string) {
return string
.replace(/^\//,”)
.replace(/(index|default).[a-zA-Z]{3,4}$/,”)
.replace(/\/$/,”);
}
var locationPath = filterPath(location.pathname);
$(‘a[href*=#]‘).each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,”) ) {
var $target = $(this.hash), target = this.hash;
if (target) {
var targetOffset = $target.offset().top;
$(this).click(function(event) {
event.preventDefault();
$(‘html, body’).animate({scrollTop: targetOffset}, 900, function() {
location.hash = target;
});
});
}
}
});
});
</script>
云里雾里的,书到用时方恨少–谁叫我是大菜鸟?请高人指点。
至此,又回到了起点。