-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: SecurityError: DOM Exception 18 #40
Comments
The same issue |
I also ran into this issue, has anyone managed to work around it yet? |
@svenvandescheur could you please put together a jsfiddle that fails for you? |
Still digging, but this fiddle will re-produce "SecurityError: DOM Exception 18" for me, on desktop Safari, mobile everything (Opera, FF, Chrome, Safari), but it works as expected with Chrome on desktop. |
sorry to say, but I cannot reproduce that since don't own a Mac 😄 |
The same issue :(. Has anyone fix it? |
@tsayen You can try using the Midori browser on Linux or Windows: http://midori-browser.org/ |
After searching the web, I couldn't find a satisfactory solution. //line95
function toPng(node, options) {
return draw(node, options || {})
.then(function (result) {
try {
var image = result.canvas.toDataURL("image/png");
return image;
} catch (err) {
console.warn(err);
return result.svg.src;
}
});
} //line 135
function draw(domNode, options) {
return toSvg(domNode, options)
.then(util.makeImage)
.then(util.delay(100))
.then(function (image) {
var canvas = newCanvas(domNode);
// after this, Canvas’ origin-clean is DIRTY
// safari will throw 'SecurityError: DOM Exception 18'
// but it can use 'data:images/svg+xml'
canvas.getContext('2d').drawImage(image, 0, 0);
return {canvas: canvas, svg: image};
});
... |
@WingGao: Actually, I had changed like you. And then it's show on browser only, but I cannot save image to file on server (cannot save data:images/svg+xml to image file). Do you have any solution for this issue? |
@thienhv295 Unfortunately, I used the server to decode the SVG but failed. |
@WingGao I just wonder why html2canvas works for you. I'm using that lib but encountered the same error: |
@evianzhow html2canvas(myElement, {useCORS: true}).then(function (canvas) {
try {
b64Data = canvas.toDataURL("image/png");
} catch (err) {
console.log(err)
}
}).catch(function onRejected(error) {
}); |
@WingGao My caveat is similar to your's. But Safari raise the exception: |
Hello! I'm getting Exception 18 in Safari too. Here's the error:
Might be related to this issue? http://stackoverflow.com/questions/33972254/svgpng-from-canvas-todataurl-throws-dom-exception-18-security-error-in-safari-9 |
@evianzhow @mtmckenna |
I have this problem and it is blocking my development as it is an Ionic app for iOS... I verified @WingGao's "solution" to use another library: html2canvas - it works but I have some rendering problems with this lib and html2canvas does not seem to be maintained anymore. Just want to contribute to prioritisation for this issue. As it works for html2canvas there 'should' be a workaround, but I don't know where to start. |
I'm having the same problem and I hope there's a solution soon. |
@pietersv I don't think that works, because it's not converting it to png. The "toDataUrl" does the png conversion, so you're skipping the png conversion step. You should just use toSvg if all you want is the svg image. The method toSvg works, since it doesn't call toDataUrl. |
I came up with a bit of a workaround. Basically, I use the toSvg method and then I take the The issue is ultimately with the |
@Digity You're right, this worked for part of the ways I used |
Here's some quick sample code for converting it to png using webshot library:
|
I am facing the same issue. Even without any images, just pure text, it is throwing a Dom exception 18 error on chrome and safari iphone versions. works ok on desktop. |
@tsayen I think it is the |
Same issue on ionic |
If you use foreign object in the svg and then converting it to canvas which contains foreign object will cause security error. |
This is a duplicate of #27. |
@WingGao I use this like you . but can not save image, do you have some advise ? |
@alanhg , see this comment in which I explain the workaround I use to make a screen shot in a Cordova application. It supports Android and iOS only but it may be extended to support additionnal browsers. Hope it will help you! |
who can copy once demo in there! |
I seem to be getting this error only in Safari when I try to save a node. The node is a div with a fixed height and width, but with nothing in it.
OS X El Capitan 10.11.5 (15F34)
Safari Version 9.1.1 (11601.6.17)
The text was updated successfully, but these errors were encountered: