【问题标题】:Skip navigation across multiple pages loaded in iframe跳过 iframe 中加载的多个页面的导航
【发布时间】:2011-08-02 08:33:40
【问题描述】:

我想在我的页面中实现跳过导航链接。所有这些跳过导航链接都在页面顶部。页面包含一个加载主要内容的 iframe。

我想要的是当用户点击页面顶部的“跳到主要内容”链接时,焦点应该设置在 iframe 内的特定元素上。

谢谢,

阿米特

【问题讨论】:

    标签: navigation accessibility hyperlink skip


    【解决方案1】:
    <script type="text/javascript">
    function skipToMainContent() {
    var frameElement = document.getElementById("frameElementId");
    // replace with your frame's id
    
    var frameDoc = frameElement.contentWindow.document || frameEle.contentDocument;
    
    frameDoc.getElementById("idOfElementToFocusOn").focus();
    // replace with your element's id
    
    }
    </script>
    
    ...
    
    <a href="#idOfIframe" onclick="skipToMainContent()">Skip to main content</a>
    

    这是你要求的吗?这就是我从你的问题中所理解的,尽管这个主题似乎暗示了其他东西(?)。

    参考http://xkr.us/articles/dom/iframe-document/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-14
      • 2011-09-22
      • 2016-07-07
      • 2021-03-25
      • 2020-09-06
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      相关资源
      最近更新 更多