2012-09-02 75 views
0

我在我的网站页面列出所有项目的拇指。当一个特定的拇指(项目)被点击时,Fancybox会在iframe中加载项目的细节。所有作品都很棒! (iframe中的内容不包括导航,标题和其他网站元素。)fancybox iframe内容和谷歌搜索

我遇到的问题是Google搜索结果页 - Google将所有详细信息页编入索引,现在当用户单击Google结果中的链接时,详细信息内容页面在浏览器中打开(而不是Fancybox iframe)。这是不好的,因为详细信息页面不包括导航页面。

任何用户友好的解决方案?

+0

从我的头顶开始,您似乎需要在每个详细信息页面中包含用于嗅探URL的脚本,并且如果在首页打开,则使用修改后的URL将其重定向到主页面....然后在主页面中,再次嗅探修改后的URL并触发在fancybox中打开适当的页面(当然,这一切都取决于结构或URL,但是您没有提供太多细节) – JFK

回答

0

正如我在我的评论中提到的,您需要在每个“详细信息”页面中包含一个脚本来嗅探URL并检测页面是否在新窗口(首页)中打开,如果是这样重定向到主页面修改后的URL(例如使用hash),这将允许从主页面打开fancybox中的“详细信息”页面。

所以,你可以在每一个“细节”页面包括这个脚本:

<script type="text/javascript"> 
var isWindow = self == top; // returns true if opened in a new window, otherwise it migh be inside an iframe 
if(isWindow){ 
// alert("this page was opened in a new browser window"); 
// then redirect to main page and add hash "detailedXX" 
window.location = "{URL}/mainpage.html#detailed01" 
} 
</script> 

变化detailed01不同的值每一个“细节”页面。

然后在主要页面,你可以有一个像

<a id="detailed01" class="fancybox" href="detailed01.html">Open project detail page 01 in fancybox</a> 
<a id="detailed02" class="fancybox" href="detailed02.html">Open project detail page 02 in fancybox</a> 

注意,我包括一个ID到每个锚相匹配的hash,我们将重新导向到主使用环节每一个细节页页。

那么你的fancybox脚本可以是这样的:

<script type="text/javascript"> 
var thisHash = window.location.hash; 
$(document).ready(function() { 
if(window.location.hash) { 
    // get the URL without hash so we can restore it if needed 
    var thisWindowLocation = window.location; 
    var thisWindowLocationSplit = String(thisWindowLocation).split("#")[0]; 
    $(thisHash).fancybox({ 
    width: 800, 
    height: 320, 
    fitToView: false, 
    autoSize : false, 
    type: 'iframe', 
    afterClose : function(){ 
    // returns URL to main page with no hash 
    window.location = thisWindowLocationSplit 
    } 
    }).trigger('click'); 
} 
// fancybox for normal main page operation 
$(".fancybox").fancybox({ 
    width: 800, 
    height: 320, 
    fitToView: false, 
    autoSize : false, 
    type: 'iframe' 
}); 
}); // ready 
</script> 

我设置DEMO here

这个演示打开两个 “详细信息” 页面:

http://www.picssel.com/playground/jquery/detailed01.htmlhttp://www.picssel.com/playground/jquery/detailed02.html

如果您尝试直接打开它们,则意志重定向t输出给calling page和的fancybox开放

1

如果您能够接受不被谷歌索引,那么你可以添加相对=“nofollow”的链接这些页面:

更多细节在这里: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=96569

+0

这是一个很好的答案,我之前想过。但是,如果您在网站中使用[Google自定义搜索](http://www.google.com/cse/)(正如我在其中一个项目中使用的那样),则可能需要将这些网页作为您的内容的一部分结果页面索引可能是必需的。 – JFK