google / google-visualization-issues

288 stars 35 forks source link

Not allowed to navigate top frame to data URL: data:image/png #2565

Open rexdarel opened 7 years ago

rexdarel commented 7 years ago

I followed the quick start guide pie chart. And I want a png of the chart also so i tried this.

`var chart_div = document.getElementById('chart_div');
        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(chart_div);

        // Wait for the chart to finish drawing before calling the getImageURI() method.
        google.visualization.events.addListener(chart, 'ready', function () {
            chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
            console.log(chart_div.innerHTML);
            document.getElementById('png').outerHTML = '<a href="' + chart.getImageURI() + '" target="_blank" class="btn bgm-blue btn-float waves-effect"><i class="zmdi zmdi-download"></i></a>';
        });
        chart.draw(data, options);`

but I've got this error in console everytime I click the button to open it in new tab. Not allowed to navigate top frame to data URL: data:image/png

I have to right click the button "png" and select Open in new tab in order to view the image.

rexdarel commented 7 years ago

I tried to open the web on other browser in Firefox and it works perfectly. I read some forums that Google Chrome removed the top navigation. How to fix this? Since Google chrome have more users than firefox. I don't want my users to get stuck

nesticle8bit commented 6 years ago

Im stuck with this problem too, idk how to fix it 😢

iaroslav-ai commented 6 years ago

I have the same issue in Chrome on Ubuntu. The "workaround" that I have thus far is to ask a user to use "Save link as ..." which works to save the file.

BouthainaTlijani commented 6 years ago

You can use this: html: <object id="obj" type="application/pdf" ></object> js: document.getElementById('obj').data = doc.output("datauristring");

sukanya124 commented 6 years ago

Not allowed to navigate top frame to data URL: data:image/png in Chrome....Can anyone help me out.... Thanks in advance

BouthainaTlijani commented 6 years ago

hello, You can use this :

var string = doc.output('datauristring'); var iframe = "" var x = window.open(); x.document.open(); x.document.write(iframe); x.document.close();

sukanya124 commented 6 years ago

Thank you for your response...but its works fine in firefox but not in google chrome...can you suggest me in another way........Thanks in advance

BouthainaTlijani commented 6 years ago

i supposed that you are using jspdf to generate pdf file and you want to open it in the navigator (in your case it's google chrome), if yes then you can use the blob option, i mean something like this: ////// var pdfUrl = doc.output('datauri').substring(doc.output('datauri').indexOf(',') + 1); var binary = atob(pdfUrl.replace(/\s/g, '')); var len = binary.length; var buffer = new ArrayBuffer(len); var view = new Uint8Array(buffer); for (var i = 0; i < len; i++) { view[i] = binary.charCodeAt(i); }

            var blob = new Blob([view], { type: "application/pdf" });
            window.open(doc.output('blob'), '_blank');

Tlijani Bouthaina bouthaina.tlijani3@gmail.com