【发布时间】:2012-01-11 21:45:17
【问题描述】:
我有文章页面。当有人从外部来源点击它们时,我怎样才能使该文章在fancybox中弹出并将索引页面作为父页面。
我的页面设置为以下格式:pages.php?id=123
我想从我的 index.php 中打开该链接,并且该 fancybox 已经打开该链接。
【问题讨论】:
标签: php jquery iframe fancybox parent-child
我有文章页面。当有人从外部来源点击它们时,我怎样才能使该文章在fancybox中弹出并将索引页面作为父页面。
我的页面设置为以下格式:pages.php?id=123
我想从我的 index.php 中打开该链接,并且该 fancybox 已经打开该链接。
【问题讨论】:
标签: php jquery iframe fancybox parent-child
您可以检查 pages.php 上的引荐来源网址以查看它是否来自外部来源,然后使用参数中的某些内容(例如 ?external=true;articleid=123)重定向到索引页面,以识别 Fancybox 应该弹出加上相应的文章。
例如,在 pages.php 上:
$(function(){
if (document.referrer.indexOf(<your url>) < 0){
window.location = "index.php?external=true;article=123";
}
});
然后在 index.php 上:
$(function(){
//Insert code here to parse query string. You can find code for this online.
var isExternal = getValueOfExternal();
var articleId = getValueOfArticleId();
if (isExternal){
//open fancybox
$.fancybox({
'href': 'pages.php?id=' + articleId
});
}
});
【讨论】: