PDA

View Full Version : JavaScript Gurus: Help with ScrollIntoView with NS/Moz vs. IE problem


tamarian
Sun 6th Jun '04, 2:19pm
I'm working on a nice spellchecker for vB, posted at vb.org

Within the spellcheck window, it uses an IFRAME, and I would like the window to scroll the contents to the highlighted word elemented (named hl).

The following line:

parent.ispellcheck.document.getElementById("h1").scrollIntoView(false);

Works fine in IE, but doesn't do much with Netscape/Mozilla/Firefox.

Anyone knows the proper syntax to get scrollIntoView to work properly?

I've tried several variatons in the (else) part below, to no avail:


hilightWord();
if (ie) {
parent.spellbox.document.getElementById("h1").scrollIntoView(false); //works for IE only !!!?!??!
}
else
{
//parent.spellbox.document.getElementById("h1").scrollIntoView(false); // does not work
document.spellbox.getElementById("hl").scrollIntoView(false);
// does not work!!!
}


You can see the entire source, if it helps. I'm just hoping it's an easy to spot problem for those familiar with how the different browsers want to call IFRAMEs.

http://www.vbulletin.org/forum/showthread.php?&threadid=65737

Scott MacVicar
Sun 6th Jun '04, 2:21pm
scrollintoview works in Mozilla but you need to pass in true and ie needs false.

We use
scrollInToView(is_moz);

tamarian
Sun 6th Jun '04, 2:39pm
scrollintoview works in Mozilla but you need to pass in true and ie needs false.

We use
scrollInToView(is_moz); I've tried it like this:

parent.spellbox.document.getElementById("h1").scrollIntoView(true);

But that was no go. I'm thinking the problem might might be in how to reference the IFRAME in moz

Each of these in the (else) part failed:

//parent.spellbox.document.getElementById("hl").scrollIntoView(true);
//document.spellbox.getElementById("hl").scrollIntoView(true);
//spellbox.document.getElementById("hl").scrollIntoView(true);
//spellbox.getElementById("hl").scrollIntoView(true);
//self.spellbox.getElementById("hl").scrollIntoView(true);
//self.spellbox.document.getElementById("hl").scrollIntoView(true);
//parent.document.spellbox.document.getElementById("hl").scrollIntoView(true);
parent.document.spellbox.getElementById("hl").scrollIntoView(true);