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/
精彩评论