Unknown error in IE7 and IE8

Unknown error in IE7 and IE8

danieleilanddanieleiland Posts: 3Questions: 0Answers: 0
edited January 2010 in General
I was struggeling to get datatables working. In my case the data loaded, but no pagination was displayed and I got a javascript error on line 503 on which datatables usses innerHTML to add the pagination to the container.
After googling around i fugured that is must have something to do with invalid markup of the page itself.
Somehow if the doctype of the page is HTML 4.01 it does not work because datatables tries to insert XHTML.
Explorer checks if the html placed with innerHTML matches the doctype, if not, it borkes.

This thread describes the same problem: http://piecesofrakesh.blogspot.com/2007/02/ies-unknown-runtime-error-when-using.html

But nevertheless, IE would not be IE if there was strange some behaviour...
In my case i use datatables on a local site: http://whatever/
Then is does not work in IE and i get an Unknown error.

But if i use http://whatever.blah.local/ it works just fine without any errors.

Beats me....

However, i hope this will help people with the same weird problem and maybe there could be an innerhtml fix.
On the previous thread there are some nice options mentioned.

Greetz,
Daniel

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi Daniel,

    Very interesting! Thanks for posting about this as I had no idea that this would be the case. But I guess that is what comes from the tag soup that is HTML. So the moral of the storey is to always use valid HTML - it's a good moral :-)

    One of the reasons DataTables uses innerHTML is for speed - it's much faster than trying to parse DOM elements - particularly in IE, and the less overhead the better. But it looks like as long as valid HTML is used, then there shouldn't be a problem.

    Regards,
    Allan
  • danieleilanddanieleiland Posts: 3Questions: 0Answers: 0
    Hi Allan,

    Indeed, it is always better to use valid HTML, but in my case i had to use datatables in an old intranet application.
    Why do you use innerHTML and not the jquery .html() method?

    Daniel
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi Daniel,

    As I mentioned, basically it's for speed. It's much faster to call core methods which are implemented by the browser than it is to use any abstraction. document.getElementById is a good example - I often see $('#example')[0] in code...

    Does it work with using $().html() instead? If so - go ahead and use DataTables modified as such :-). It looks like it would be a trade off between speed and supporting invalid HTML in that case - which isn't really something I would want to do in DataTables.

    Regards,
    Allan
  • danieleilanddanieleiland Posts: 3Questions: 0Answers: 0
    Hi Allan,

    I fully agree about the valid html, but in some cases that's impossible.
    I will change my local copy to work with the .html() method to fix this specific issue.

    Maybe it's an idea to have a strict/loose setting. Strict uses innerHTML, loose uses .html()

    :)

    Regards,
    Daniel

    By the way, i realy like the solution you implemented regarding the session state. Much better than my MD5 approach :)
  • schauol1schauol1 Posts: 1Questions: 0Answers: 0
    Hi Allan,

    I'm facing the same Problem...

    IE8 fails with this Error:
    Unknown Runtime Error: ZeroClipboard.js, line 135 charachter 3

    The Line from this js:
    this.div.innerHTML = this.getHTML( box.width, box.height );

    Above you've been talking about using jQuery-Markup as a "quickfix"... looks like im to stupid, but I can't get it to work. :-)

    How can I fix this?

    Thank you for any Help,

    Oliver
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    I don't remember this thread particularly well (given that it was more than a year ago :-) ), however it looks like the solution from what I said before is to use valid HTML. Is that a modification you can make? Otherwise, you could perhaps try $(this.div).html( this.getHTML( box.width, box.height ) ); and see if that does it.

    Allan
This discussion has been closed.