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.

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

报告相同问题?

悬赏问题

  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人