2012-01-18 59 views
1

基本上,我试图设置一个页面,以便当一个链接被点击时,它将在iframe中打开,但父页面的URL将更新与哈希但iframe的网址将是原点击url(没有散列)。我达到了初始点击事件起作用的地步。但更改事件(如果用户直接链接到页面)不起作用。这里是我的代码片段:jquery地址和iframes

$j('.products-grid .item a, .post a').click(function(){ 
    $details.fadeIn().addClass('active'); 
    $j.address.value($j(this).attr('href').substr(2)); 
    $details.animate({left:detailGap}, { duration: 500, easing: 'easeInOutExpo'}); 
}); 

    }).change(function(event) { 
     $iframe.attr('src', event.value); 
     $details.fadeIn().addClass('active'); 
     $details.animate({left:detailGap}, { duration: 500, easing: 'easeInOutExpo'}); 
     var loadurl = location.origin + location.pathname +location.hash.substr(1); 
     alert(loadurl); 
     $iframe.attr('src', loadurl); 
    }); 

即:为URL,http://www.url.com/product-1(iframe网址) 我希望它显示为http://www.url.com/#/product-1(页面URL) 这是在Magento。

感谢,罗伯特

回答

0

想通了

$j('.products-grid .item li a').click(function(){ 
      $j('html, body').animate({scrollTop: '0px'}, 100); 
      $j.address.value($j(this).attr('href')); 
      $details.fadeIn().addClass('active'); 
      $j('body').addClass('open'); 
      $iframe.attr('src', 'about:blank'); 
      $details.animate({'left':detailGap - navGap}, { duration: 500, easing: 'easeInOutExpo'}); 
}); 

打开滑出面板我创建了安置的iframe。

我将目标设置为iframe,以便在其中打开URL。但仍然允许深度链接。

,你可以在这里看到最终的解决方案:

http://www.echodesign.com/