Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] How to block links inside an Epub #511

Open
vichenze opened this issue Mar 23, 2016 · 1 comment
Open

[question] How to block links inside an Epub #511

vichenze opened this issue Mar 23, 2016 · 1 comment

Comments

@vichenze
Copy link

I use cloud reader lite to display an epub. Since there is no support for content tagged epub:type noteref, I made it myself (based on a script from epub.js) and I add it inside the epub content.

This works really fine on desktop, there is a small popover displayed on mouseover near the word to be defined. But on tablet, there is no onmouseover event, just the click event.

And when I click a link, the link is followed, whether it's an external link or an anchor.

var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++)
{
    if (links[i].getAttribute('epub:type') === 'noteref')
    {
        links[i].addEventListener("mouseover", showPop, false);
        links[i].addEventListener("mouseout", hidePop, false);
        links[i].addEventListener("click", disableClick, false);
    }
}

function disableClick(e)
{
    console.log('I was clicked');

    e.preventDefault();
    e.stopPropagation();
}

"I was clicked" is displayed but the preventDefault() does nothing, the click event is not stopped.

How can I prevent a link in the epub to open a new tab or to go the corresponding anchor ?

@danielweck
Copy link
Member

Just to be clear, there is support for EPUB3 "popup" footnotes in a feature branch, in fact we discussed progress during one of last week's conference calls.

#505

(includes demo links)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants