我在fancybox 1.3.7中使用此代码。当fancybox打开url更改到相应的div(/ page#div-id)时,它关闭时应该返回到/ page但注释的函数不起作用。我不得不使用如下所示的临时值。我怎样才能解决这个问题?打开和关闭fancybox时更改url
window.onload = function(){
function showfb(id) {
if (/^#.*/.test(id)) {
$(id).show();
$.fancybox({
href: id,
type:'inline',
position: 'center',
'transitionIn': 'fade', // elastic, none, ease, fade
'transitionOut': 'fade',
onClosed: function(){
//$(id).hide();
window.location.hash = "_"; // temporary
}
});
}
}
showfb(location.hash);
$('a.profile').click(function(e){
showfb($(this).attr('href'));
});
};
你为什么这样做'$( 'a.profile')点击(函数(E){showfb($(本).attr ('href'));});'而不是'$('a.profile')。fancybox()'? – JFK