How to make links to HTML ids work

Hi, I am creating a CMS kind of application and I would like to add a visual index to a page. A page has an H1 title and each paragraph is an H2. All H2's are in the index. I would like to make the index clickable so the reader can jump to the appropriate section. However, using <a href=#someid> and <div id=someid> does not work. You see the page jump to the appropriate position but immediately the browser jumps to the homepage. It seems that the Mx framework does not accept this because it cannot handle direct URL's. How can I make this work? Regards, Paul
3 answers

I also needed something like that and ended up making a widget with code for the onclick:

$('html,body').animate({scrollTop: $("."+this.theDiv).offset().top+(parseInt(this.yOffset))}, this.duration);

Maybe you can put something like this with hardcoded values in an html snippet and attach it as an onclick attribute value


You could also try to make use of the deeplink module from the appstore:


I ended up with this and it works fine:

'<li><span onclick=document.getElementById("'+ $Article/ArticleID + '").scrollIntoView();>' + $Article/Title + '</span></li>'