ASP.net Web 表单和 Fancybox 不会在页面加载时加载预定义图像
我有一个使用 fancybox 展示的照片库,效果很好。我需要添加额外的功能,以便用户可以通过电子邮件与他们的朋友分享照片链接等。
我正在使用 asp.net Web 表单 C# 以及我的主相册的母版页设计,并且我使用 iframe 从我的主 Photogallery.aspx 页面加载带有 fancybox 的图库。
现在工作正常,我希望用户打开主页 Photogallery.aspx 上的精美框中共享我的电子邮件的相同链接。
我使用java脚本来检查查询字符串“emailImgID”是否存在,然后我触发一个隐藏链接来加载fancybox,但它不起作用,但下面是最新版本的代码。我尝试过不同的方法,但似乎不起作用..
<script src="Scripts/jquery-1.6.min.js" type="text/javascript"></script>
<script src="fancybox/jquery.fancybox-1.3.4.pack.js" type="text/javascript"></script>
<link href="fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="style.css" />
<script type="text/javascript">
$(document).ready(function () {
$("a.iiframe").fancybox({
'scrolling': 'no',
'width': 830,
'height': 650,
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'iframe'
});
$.extend({
getUrlVars: function () {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function (name) {
return $.getUrlVars()[name];
}
});
// i use this part to trigger link event so that it can load fancy box rather it shows only loading icon and doesnt load fancybox
var urlVars = $.getUrlVars();
if (urlVars['emailImgID'] != "") {
$("#MainContent_hidden_link").fancybox().trigger('click');
}
});
</script>
I have a photo-galley which i show using fancybox, It works fine. i need to add additional functionality so that user can share photograph link by email with their friends and so on.
I am using asp.net web form c# along with master-page design for my main photogallery and i load gallery with fancybox using iframe as from my main Photogallery.aspx page.
It works fine now i want user to open the same link shared my email in fancy box on the main page Photogallery.aspx.
I use java script to check if query-string "emailImgID" is present then i trigger a hidden link to load the fancybox but it doesn't work but below is the latest version of code. I have tried different thing but it doesn't seems to work..
<script src="Scripts/jquery-1.6.min.js" type="text/javascript"></script>
<script src="fancybox/jquery.fancybox-1.3.4.pack.js" type="text/javascript"></script>
<link href="fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="style.css" />
<script type="text/javascript">
$(document).ready(function () {
$("a.iiframe").fancybox({
'scrolling': 'no',
'width': 830,
'height': 650,
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'iframe'
});
$.extend({
getUrlVars: function () {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function (name) {
return $.getUrlVars()[name];
}
});
// i use this part to trigger link event so that it can load fancy box rather it shows only loading icon and doesnt load fancybox
var urlVars = $.getUrlVars();
if (urlVars['emailImgID'] != "") {
$("#MainContent_hidden_link").fancybox().trigger('click');
}
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要获取 URL 的查询字符串部分,请使用
location.search
。将 getUrlVars 方法更改为。
并像这样检查
To get the querystring part of the url use
location.search
.Change
getUrlVars
method to.And check like this
工作脚本:我管理代码以对脚本进行细微更改,现在工作正常
Working Script: I managed code to work with minor change to the script, It works fine now