情境:
首先,有一个id为miframe的iframe,展示一个带有锚点suchen的网站,即:
<div id="suchen"></div>.
第二步。父框架。
目标:在父框架内创建一个看起来像这样的链接
<a class="LINK0" title="" href="javascript:springen('suchen');">w/e</a>
使iframe中的内容滚动到锚点suchen。我的方法是:
function springen(anker) {
var childWindow = document.getElementById("miframe").contentWindow;
// this should emulate a click on the ptAnchor DIV's child A HREF.
//childWindow.document.getElementById(anker).firstChild.click();
//childWindow.document.getElementById(anker).scrollIntoView();
// alternatively, this will simply scroll the child window to the top-left corner
//childWindow.scrollTo(0,200);
}
childWindow.scrollTo(0,200);
可以实现滚动到200像素的位置。
但我需要滚动到iframe中任何位置的标记处。有什么想法吗?