Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay, so I discovered a solution to my problem. I just needed to surround my JavaScript in CDATA tags like so:</p> <pre><code>//&lt;![CDATA[ var genArray = function () { var arr, len, i; if(arguments.length &gt; 0) { len = [].slice.call(arguments, 0, 1)[0]; arr = new Array(len); for(i = 0; i &lt; len; i++) { arr[i] = genArray.apply(null, [].slice.call(arguments, 1)); } } else { return null; //or whatever you want to initialize values to. } return arr; } //]]&gt; </code></pre> <p>I discovered this by using the <a href="https://code.google.com/p/epubcheck/wiki/Running" rel="nofollow noreferrer">epubcheck</a> tool which said something to the effect that the file must have properly formed characters or something. I don't recall the exact message. Anyways, this reminded me of a problem I had in a script where I used some unicode characters. I remembered about CDATA which solved it. Then I found <a href="https://stackoverflow.com/questions/66837/when-is-a-cdata-section-necessary-within-a-script-tag">this</a> stackoverflow question which basically says it's necessary for when your pages must be interpreted as XML/XHTML as well, which is the case for ePubs.</p> <p>So, moral of the story is wrap javascript in CDATA tags for ePubs or iBooks.</p> <p>EDIT: It should be noted that it's worth doing this around <strong>all</strong> of your JavaScript. The issue in my case was the <code>&lt;</code> less than operator being interpreted as the start of a tag. However, it is probably cleaner to just include the CDATA tag around all of your JavaScript rather than trying to isolate sources of the issue.</p> <p>EDIT 2: In the interest of aggregating information to whoever finds this answer useful, it should also be noted that having all of one's JavaScript in external files probably also works (according to the source linked in the answer to the question I've linked to). I don't care to test this at the moment, but it should work because the external JavaScript will not be parsed as XML like it is inside of a <code>&lt;script&gt;</code> tag. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload