Is there a way to scroll an object into view of the user's screen, or viewport, if it is not already? For example, if I perform some action and I have a reference to an object which currently is scrolled out of view, is there a way to scroll that object into view? Can this be done with just the object reference, or will its position need to be determined as well?
I just found an IE-specific method named scrollIntoView(), which does exactly what I was asking for. Is there a similar method that Mozilla browsers use, or does someone know of a method that was written to simulate this effect?
Doesn't that figure.... I just tried it out and you are right, thank you. I must have a book that is out of date because it says that the scrollIntoView() method is for IE only.
No problem. Your book is somewhat correct because I believe it actually started as an IE-only method and then Mozilla just eventually chose to implement it as well. Much like with other non-standard things such as innerHTML. Further, I believe you could emulate HTMLElement.scrollIntoView via fragment idendifiers, or via the method as described on this page.
Bookmarks