- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
toDataURL throw Uncaught Security exception in HTML
To solve the Uncaught Security Exception, you need to add the crossorigin attribute:
<img id = "myid" crossorigin = "anonymous" src="https://www.tutorialspoint.com/images/seaborn-4.jpg?v=2"> function getBase64() { var myImg = document.getElementById("myid"); var c = document.createElement("canvas"); c.width = myImg.width; c.height = myImg.width; var context = c.getContext("2d"); context.drawImage(img, 0, 0); var dataURL = c.toDataURL("image/png"); alert(dataURL.replace(/^data:image\/(png|jpg);base64,/, "")); } getBase64();
Advertisements