douchenzhan3050 2014-10-16 00:41
浏览 22
已采纳

什么是最好的目标= _parent替代?

I have two views on a page, a slideshow view, and a grid view. Each slide has a hash associated with it in slideshow view. In grid view, a display of all the links associated with each slide are present. If you click on it, it should take you back to that slide and reload the page. target="_parent" seems to work, but it is only supported in IE. target="_blank" works but I need to avoid opening in a new window since it should just reload the page you are on except take you to that specific hash. Any alternatives to target="_parent"?

EXAMPLE: http://bigredsun.staging.wpengine.com/our-work-index/

  • 写回答

1条回答 默认 最新

  • dongxi5423 2014-10-16 01:03
    关注

    You should see the Page loaded. #[1-5] in the console when you click the links:

    <a href="#1">Test #1</a><br/>
    <a href="#2">Test #2</a><br/>
    <a href="#3">Test #3</a><br/>
    <a href="#4">Test #4</a><br/>
    <a href="#5">Test #5</a>
    
    window.addEventListener('load', function load(){
        console.log('Page loaded.', location.hash);
    
        var a = document.getElementsByTagName('a');
    
        for (var i = 0; i < a.length; i++) {
            a[i].addEventListener('click', function click(){
                window.location = this.href;
                window.location.reload(true);
            });
        }
    });
    

    jsFiddle seems to have a problem with it not being a POST, so no live demo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大