Judging by the error message, you are using a Webkit-based browser, most likely Chrome. This error message (presented here ) is displayed when the <iframe> element with the sandbox attribute tries to run JavaScript (only allowed when allow-scripts is specified in this attribute). A look at the source code of rasterizeHTML shows that the createHiddenSandboxedIFrame () function creates such a frame. It is used for calculateDocumentContentSize() , the contents of the document are copied into a temporary isolated frame to measure their size. Apparently, this document also contains <script> tags and they cause an error (not because of the source of the script, but because scripts are usually forbidden).
Now your code does not call calculateDocumentContentSize() , of course. It is called by drawDocumentImage() , called by doDraw() , called by rasterizeHTML.drawDocument() , called by rasterizeHTML.drawHTML() . In the end, the problem is valid: the HTML code you pass contains the <script> tags.
Given that running scripts in the HTML you are drawing does not seem to be intent (no executeJS ), you should just move the <script> tags somewhere else, t inside the mattes element. If this is not possible, you can still run some regular expression in the source code to remove all script tags, for example:
var code = document.getElementById("mattes").innerHTML; code = code.replace(/<\/?script\b.*?>/g, ""); rasterizeHTML.drawHTML(code, canvas);
Edit : ondrop event handlers, such as the ondrop attribute, will also ondrop this warning. You can also delete them:
code = code.replace(/ on\w+=".*?"/g, "");
Please note that this will help you get rid of the warning. I doubt this warning is what causes the image to be blank - so you probably need to ask another question.
source share