Javascript / Prototype problem: I've written a function that inserts new content in a div whenever you click on a link in that same div. It works, but with the added "feature" of scrolling to the top of the page after the new content has been added. I don't want it to do this. How do I stop it? Here's
. (Scroll down to see the link.)
[script src="prototype.js" type="text/javascript"][/script]
[script]
Event.observe(window,"load",onWindowLoad);
function onWindowLoad()
{
Event.observe("addMoreContent","click",onAddMoreContentClicked);
}
function onAddMoreContentClicked()
{
new Insertion.Bottom("div2","[p]more content[/p]")
scrollTo("div2"); //this line has no effect, but see
here.
// $("div2").scollTo //-- doesn't work either
}
[/script]
...
[div] lorem ipsum... [/div] [!-- scrolls to here if you click the link below!! --]
[div id='div2']
[a href="#" id='addMoreContent']add more content[/a]
[/div]
posted by mikeh at 7:09 AM on May 2, 2007