diff --git a/src/Core.js b/src/Core.js index 1e8478a..0cef04e 100644 --- a/src/Core.js +++ b/src/Core.js @@ -36,8 +36,6 @@ html2canvas.Util.backgroundImage = function (src) { }; html2canvas.Util.Bounds = function getBounds (el) { - - window.scroll(0,0); var clientRect, bounds = {}; @@ -109,9 +107,9 @@ html2canvas.Util.getCSS = function (el, attribute) { if ( rsLeft ) { el.runtimeStyle.left = rsLeft; }*/ - val = $(el).css(attribute); + // val = $(el).css(attribute); // } - return val; + return $(el).css(attribute); }; @@ -128,5 +126,12 @@ html2canvas.Util.Extend = function (options, defaults) { html2canvas.Util.Children = function(el) { // $(el).contents() !== el.childNodes, Opera / IE have issues with that - return $(el).contents(); + var children; + try { + children = $(el).contents(); + } catch (ex) { + html2canvas.log("html2canvas.Util.Children failed with exception: " + ex.message); + children = []; + } + return children; } diff --git a/src/Parse.js b/src/Parse.js index 63c6831..8dc2f41 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -11,7 +11,7 @@ */ html2canvas.Parse = function (element, images, opts) { - + window.scroll(0,0); opts = opts || {}; // select body by default @@ -175,14 +175,14 @@ html2canvas.Parse = function (element, images, opts) { - - // TODO add another image - img.src = "http://html2canvas.hertzen.com/images/8.jpg"; + // http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever (handtinywhite.gif) + img.src = "data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs="; img.width = 1; img.height = 1; img.style.margin = 0; img.style.padding = 0; + img.style.verticalAlign = "baseline"; span.style.fontFamily = font; span.style.fontSize = fontSize; diff --git a/src/Preload.js b/src/Preload.js index 878cdf1..03fab51 100644 --- a/src/Preload.js +++ b/src/Preload.js @@ -156,7 +156,8 @@ html2canvas.Preload = function(element, opts){ contentsLen = contents.length, background_image, src, - img; + img, + elNodeType = false; for (i = 0; i < contentsLen; i+=1 ){ // var ignRe = new RegExp("("+this.ignoreElements+")"); @@ -166,8 +167,14 @@ html2canvas.Preload = function(element, opts){ } // } - - if (el.nodeType === 1 || el.nodeType === undefined){ + try { + elNodeType = el.nodeType; + } catch (ex) { + elNodeType = false; + html2canvas.log("html2canvas: failed to access some element's nodeType - Exception: " + ex.message); + } + + if (elNodeType === 1 || elNodeType === undefined){ background_image = html2canvas.Util.getCSS(el, 'backgroundImage');