Sketchfab Forum

getScreenShot in Edge

(Charper) #1

getScreenShot in edge is opening a new window without any contents. This works in Chrome, Firefox, and Opera without problem. Here is the code

api.start(function () {
	$("#screenshot").click(function () {
		api.getScreenShot("image/png", function (err, result) {
			var height = $("#model-iframe").height();
			var width = $("#model-iframe").width();
			if (height < 100) {
				height = 100;
			if (width > 100) {
				width = 100;
			}, "_blank");

(Paul Sketch) #2

"result" is a URL encoded image and thus prone to URL length hard limits that depends on browsers vendors implementations

You can try to either:
- use jpeg
- a smaller image by using a smaller sketchfab iframe (gives smaller url encoded)
- use blob/createdataURL if you need png and support any resolution (see &&

(Charper) #3

Thanks! I had no idea that would be an issue with Edge. I've tried to implement that blob approach. It works fine in Chrome and Firefox, but Edge is returning a "SCRIPT5: Access is denied." when I execute Any ideas? Could Edge think the blob is cross-domain?
Here's the code that's being passed the data uri and opening the window:

                            var byteString = atob(result.split(',')[1]);
                            var mimeString = result.split(',')[0].split(':')[1].split(';')[0]
                            var ab = new ArrayBuffer(byteString.length);
                            var ia = new Uint8Array(ab);
                            for (var i = 0; i < byteString.length; i++) {
                                ia[i] = byteString.charCodeAt(i);

                            var blob = new Blob([ab], { type: mimeString });
                            var url = URL.createObjectURL(blob);

(Paul Sketch) #4

from seems the anwser might be

if (window.navigator && window.navigator.msSaveOrOpenBlob) {
else {
    var objectUrl = URL.createObjectURL(blob);;

(Charper) #5

Thanks! Works perfectly!