Is there any way to run javascript in iBooks without user interaction?

别来无恙 提交于 2019-12-07 18:18:28

I assume you are talking about a book authored using iBooks Author, which by the way would be a useful detail to put in your question. I don't know iBooks Author or its widget architecture or to what it extent it exposes the ability to place JS on a page.

However, in "normal" ebooks authored in (X)HTML/JS/CSS, there is no essential difference between JS in the reader and in a web browser.

I'm not sure what you mean by "running in the background"; JS runs when something tells it to, whether that something is it being placed on a page in a SCRIPT element, or put it in an onLoad or some other event handler.

Widgets in ibooks do not execute JS until they are activated by the user. So even though the link for the widget may be visible in your book, it's not capable of making connections via ajax or doing anything else until launched. Once launched, the widget has no access to the book content either. If you wanted to run mixpanel in a widget you could, but it wouldn't make sense unless your widget also contained all the content of the book (and a reading system).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!