【发布时间】:2012-02-20 03:33:09
【问题描述】:
我需要当我点击任何使用 fancybox 的东西时,它会为此生成一个特定的 URL,所以当我将此链接发送给某人时,它会打开我想要的特定框。
例如: fancybox.net/home 当我点击第一张图片时,链接仍然 fancybox.net/home 我希望当我点击图片时,会生成 URL 并出现在地址栏中,例如:fancybox.net/home/imageid=1 因此,当我将 fancybox.net/home/imageid=1 发送给某人时,它已经打开了框中的图像
谢谢!
(就像facebook照片,当你点击任何照片时,照片会在一个盒子里打开,但地址栏会变成图片链接)
////// 更新#1 //////
我按照 JFK 的建议做了,但经过一小时的尝试,我仍然不知道为什么这些盒子不一样。
看看两者的区别:
代码:
<script type="text/javascript">
var thisHash = window.location.hash;
$(document).ready(function() {
if(window.location.hash) {
$(thisHash).fancybox({
prevEffect : 'none',
nextEffect : 'none',
closeBtn : false,
arrows : true,
nextClick : true,
helpers : {
thumbs : {
width : 80,
height : 80
},
title : {
type : 'inside'
},
buttons : {}
},
afterLoad : function() {
this.title = (this.index + 1) + ' de ' + this.group.length + '<div id="curti"><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.google.com.br&send=true&layout=standard&width=45&show_faces=false&action=like&colorscheme=light&font&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:56px; height:24px;" allowTransparency="true"></iframe></div>';
}
}).trigger('click');
}
$('.fancylink').fancybox({
prevEffect : 'none',
nextEffect : 'none',
closeBtn : false,
arrows : true,
nextClick : true,
helpers : {
thumbs : {
width : 80,
height : 80
},
title : {
type : 'inside'
},
buttons : {}
},
afterLoad : function() {
this.title = (this.index + 1) + ' de ' + this.group.length + '<div id="curti"><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.google.com.br&send=true&layout=standard&width=45&show_faces=false&action=like&colorscheme=light&font&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:56px; height:24px;" allowTransparency="true"></iframe></div>';
}
});
}); // ready
</script>
那个脚本有什么问题?
【问题讨论】:
-
在触发它的链接上调用
click()。 -
我是新手,我该怎么做?