rschroll / efm

Epub for Monocle — A pure javascript implementation of the book data interface for Epub2 and Epub3
http://rschroll.github.com/efm
44 stars 15 forks source link

IE - SCRIPT438: Object doesn't support property or method 'getAttribute' #7

Open pateljatin opened 9 years ago

pateljatin commented 9 years ago

Hello,

First of all - this is great work! Works awesome!

I'm seeing this problem in IE where IE is throwing an error as follows:

SCRIPT438: Object doesn't support property or method 'getAttribute'

it's pointing to func parseOPF(reldir) {} - line 107 - col 17 - at:

                var id = item.getAttribute("id");

I was wondering if anyone has come across this issue? I also tried to load the demo site in IE and load an ePub and it doesn't work properly there either...

Thanks, JP

rschroll commented 9 years ago

That's odd.

I don't have easy access to IE to test this, but could you try changing line 106 to "var item = items[i]". A stack exchange answer noted that this sometimes happens with global variables that have the same name as HTML elements in IE. There's no reason for item to be global; I was probably just sloppy when I wrote it.

pateljatin commented 9 years ago

Yep, that does fix it however - now another one showed up - I hate IE.

Unable to get property 'split' of undefined or null reference
line 52, col 5
function joinPaths(path1, path2) {
    var path = path1.split('/').concat(path2.split('/'))

for some reason it believes path is empty - hmm

Thanks, JP

rschroll commented 9 years ago

I wish it knew which path it thought was empty. Everywhere joinPaths() is called, path1 should be non-null (although it may be the empty string). path2 is read out from some file within the epub, so a bad epub could give us problems. (As I note in the README, efm doesn't do any error checking.) Does this happen for many epubs, or just one particular one? Do the problematic epubs open in with efm in other browsers?

If you feel like doing some debugging, it would help to know which call and which argument of joinPaths is the problem. The easiest way would be to just sprinkle some console.log() calls around.

I've found some other Javascript sloppiness, so I'll clean them all up together in a commit. We'll leave this bug open for now, though.

pateljatin commented 9 years ago

Yep, I started debugging this - it's odd - looks to me after all the paths are done for some reason, it doesn't like the last one. Anyhow, I got past that by checking for '/' prior to split - probably doesn't make sense but for some reason IE likes it that way. However, now it's stuck somewhere further down...I'll let you know as I dig more...

I've been testing few ePubs - one being Harry Potter (book 1), which works fine on all other browsers except IE. I'm testing this on Win 8.1 (IE 11).

Thanks-

pateljatin commented 9 years ago

Hi,

Not sure if anyone found a solution to this? I didn't get a chance to spend more time on this.

Thanks-

yxbwzx commented 8 years ago

Hi,I found the issue is caused by that there is nothing in the title tag in html file( file under the unzip epub file path).

rschroll commented 8 years ago

On Wed, Oct 21, 2015 at 4:31 AM, yxbwzx notifications@github.com wrote:

Hi,I found the issue is caused by that there is nothing in the title tag in html file( file under the unzip epub file path).

To which issue are you referring, the getAttribute problem or the split problem? I also don't understand why the title tag should matter -- EFM never looks at them. Chapter titles come from the nav file or the NCX file, depending on the version.

yxbwzx commented 8 years ago

I test with epub2.0.1 version file,the epub3.0 crashed in chrome. Both IE11 and chrome get the same base64 string parsed by zipjs, the '' tag doesn't work in IE8,IE9 and IE11, but works well in chrome the 'some words' tag works well in IE11 and chrome but IE8,IE9. Maybe it's IE's bug?