【问题标题】:fancybox: opening external child page loads parent page behind it花式框:打开外部子页面会在其后面加载父页面
【发布时间】:2012-01-11 21:45:17
【问题描述】:

我有文章页面。当有人从外部来源点击它们时,我怎样才能使该文章在fancybox中弹出并将索引页面作为父页面。

我的页面设置为以下格式:pages.php?id=123

我想从我的 index.php 中打开该链接,并且该 fancybox 已经打开该链接。

【问题讨论】:

    标签: php jquery iframe fancybox parent-child


    【解决方案1】:

    您可以检查 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
        });
      }
    });
    

    【讨论】:

    • 我有点明白你在说什么。我将如何传递参数并在 index.php 上设置一些东西,以便它自动加载它。任何示例代码?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多