15
rated 0 times
[
16]
[
1]
/ answers: 1 / hits: 18513
/ 12 Years ago, sat, december 15, 2012, 12:00:00
Situation:
First: iframe with id miframe, displaying a site with the anchor called suchen, i.e.
<div id=suchen></div>.
Second. Parent frame.
Goal: Make a link within the parent frame looking like
<a class=LINK0 title= href=javascript:springen('suchen');>w/e</a>
make the content in the iframe be scrolled to the anchor suchen. My approach.
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);
works in so far, that scroll happens to 200.
But I need scrolling to the very anchor, wherever it is in the iframe. Ideas?
More From » html