There are a few ways to handle event stopping. Here is a solution I think will work best in your case. Of course, loading pages or links this way has its own caveats that we will not go too deep into here.
Here is the full code: Example on jsFiddle
First we track the clicks within our target surface and call the function to check if it is a link. If we clicked on a link we will emit an event passing the target href.
this.mySurface.clickNullifier = function (e) {
if (e.target && e.target.nodeName == 'A' && e.target.href) {
this.mySurface.emit('href-clicked', { data: { href: e.target.href } })
return false;
}
}.bind(this);
this.mySurface.on('deploy', function () {
// sets up the click function on the surface DOM object
this._currentTarget.onclick = this.clickNullifier;
});
Now that the surface clicks are tracked we will capture any intercepted clicks and load them into an iFrame or if local links load them in using the loadURL utility in famous.
this.mySurface.on('href-clicked', function (event) {
console.log(event.data);
// handle your code for the iframe
// not always doable in the case of 'X-Frame-Options' to 'SAMEORIGIN'
loadIframe.call(this, event.data.href);
// or loadURL like here. Needs CORS open on the href server if cross origin
//Utility.loadURL(event.data.href, loadLink.bind(this));
}.bind(this));
function loadIframe(content) {
this.backSurface.setContent('<iframe src="' + content + '" frameborder="0" height="100%" width="100%"></iframe>');
};
Bonus: In the example link above, you will see that the click event still fires on the surface. You can see by watching the console log.