html5shiv
html5shiv copied to clipboard
ownerDocument.namespaces throws 'unspecified error' in IE8
I'm using html5shiv in a project, and I have random errors here:
function shivPrint(ownerDocument) { var shivedSheet, wrappers, data = getExpandoData(ownerDocument), namespaces = ownerDocument.namespaces, ------> Here I got an error ownerWindow = ownerDocument.parentWindow; ....
This function is called from: shivPrint(document);
The javascript console throws this info about the error: 'unspecified error' in line...
It seems the ownerDocument (the document) is not set or initialized correctly at this point, and it happens only sometimes. To avoid this error, I wait to window.onload event to call this function.
// Wait for onload to avoid load document error in IE8 window.onload = function() { // shiv for print shivPrint(document); }
@juafrlo
Thanks for your bugreport. I will look into this soon. The onload event might be to late. We could try to use a IE-only domcontentready method. Additionally window.onload = your function, can be overwritten or overwrites other event handler. It's not save.
@juafrlo's fix worked for us - would be nice to get this fix formalized. (found this project and bug via modernizr)