ontouchstart doesn't validage in epubckeck for ibooks

2 posts / 0 new
Last post

We are using basic programing with xhtml and css to make an interactive epub book for the ipad and ibooks. We are not using ibookauthor. We want to have a button that will pop up a new window or frame on the page if it is clicked. This window could have a new photo or text in it. We are following the directions in apple's epub guide 4.8 that indicated to use ontouchstart. But our epub book fails the epubcheck for this feature. Epubcheck flags this as "ontouchstart not allowed here". Is this a false positive on epubcheck? What code could we use for validation? DRK5

Epubcheck is validating to the HTML5 specification, which doesn't include Touch Events (see the event handlers in the global attributes list, for example). Touch Events 1 is still a CR and Events 2 an Editor's Draft, so there isn't a stable reference at this point, which may be one factor. I checked on validator.nu out of curiosty, and it flags touch events as invalid, too.

That doesn't mean they can't be supported, as obviously they are in use in browsers and reading systems, and EPUB does provide a mechanism for testing for the functionality. You might want to log an issue on the epubcheck code site.

You could also use an event listener to get around validation issues:

document.getElementById('touchable').addEventListener('touchstart', function(ev) { ... });

But if Apple explicitly states the attributes can be used, then perhaps you can also just ignore the validation errors. I don't know, as I don't have access to the document you mention. It would be highly advisable to contact their support people and check than take my advice on that count!

Assuming you're creating an EPUB 3, as I mentioned above you should also be able to test the reading system to determine if it can handle touch events using the epubReadingSystem object as follows:

 

var hasTouchEvents = navigator.epubReadingSystem.hasFeature("touch-events");

Hope that helps.

Secondary menu