开发者

Skip navigation across multiple pages loaded in iframe

I want to implement skip nav开发者_StackOverflow社区igation links in my page. All this skip navigation links are at the top of the page. Page contains an iframes which loads main content.

What i want is when user clicks on "Skip to main content" link at the top of the page, the focus should be set on particular element that is inside iframe.

Thanks,

Amit


<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>

Is this what you're asking for? That's what I understood from your question though the subject seems to suggest something else (?).

Reference: http://xkr.us/articles/dom/iframe-document/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜