Click here to Skip to main content
14,739,661 members
Home » Discussions » JavaScript
   

JavaScript

 
AnswerRe: function with OR Pin
Richard MacCutchan29-Oct-20 11:41
mveRichard MacCutchan29-Oct-20 11:41 
SuggestionJSMAN - JavaScript Map alternative notation Pin
Member 1497706227-Oct-20 18:35
MemberMember 1497706227-Oct-20 18:35 
GeneralRe: JSMAN - JavaScript Map alternative notation Pin
Sandeep Mewara27-Oct-20 20:34
mvaSandeep Mewara27-Oct-20 20:34 
Questionfind low distance from two matrices Pin
costy3527-Oct-20 7:57
Membercosty3527-Oct-20 7:57 
GeneralRe: find low distance from two matrices Pin
Richard MacCutchan27-Oct-20 8:14
mveRichard MacCutchan27-Oct-20 8:14 
GeneralRe: find low distance from two matrices Pin
costy3527-Oct-20 12:18
Membercosty3527-Oct-20 12:18 
GeneralRe: find low distance from two matrices Pin
Richard MacCutchan27-Oct-20 22:49
mveRichard MacCutchan27-Oct-20 22:49 
QuestionConverting image file format Pin
Valentinor27-Oct-20 0:40
MemberValentinor27-Oct-20 0:40 
I am trying to make an add-on for Mozilla Firefox that will convert an image (from a given direct link) to another format and then give the user the save file pop-up.

I have tried to use JavaScript to turn the image into a canvas, and then the canvas to an image with the format wanted, but I run into the problem with canvas.toDataURL, that doesn't allow to use an image from another origin, and I get Uncaught DOMException: The operation is insecure. How else can I do this image conversion? I know it is possible to do it, because there are other add-ons that do this, but my add-on will have other specific functions for our work beside only image conversion, and we can't use those because of that.

I'm doing the testing in straight HTML, because it is easier to do it this way, then keep refreshing the add-on in browser.

Here is the code:
<!DOCTYPE html>
<html>
<head>
	<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
	<meta content="utf-8" http-equiv="encoding">
</head>
<body>
<script>
window.onload = function() {
	var image = new Image();
    image.addEventListener("load", imageLoaded, false);
	image.src = "theLinkToAnImage";
};

function imageLoaded() {
	var canvas = document.createElement("canvas");
	canvas.width = this.width;
	canvas.height = this.height;
	canvas.getContext("2d").drawImage(this, 0, 0);

	var image = new Image();
	image.crossOrigin = "Anonymous";
	image.src = canvas.toDataURL("image/jpg");
	document.body.appendChild(image);
}
</script>
</body>
</html>


modified 27-Oct-20 6:59am.

QuestionGoogle Map API & JavaScript Issue (Snowload Calculator) Working Model for easier troubleshooting Pin
Member 1497471825-Oct-20 5:31
MemberMember 1497471825-Oct-20 5:31 
QuestionXML NodeList Java object showing null in Nashorn Javascript Pin
shampoo7224-Oct-20 10:40
Membershampoo7224-Oct-20 10:40 
AnswerRe: XML NodeList Java object showing null in Nashorn Javascript Pin
Richard MacCutchan24-Oct-20 22:59
mveRichard MacCutchan24-Oct-20 22:59 
GeneralRe: XML NodeList Java object showing null in Nashorn Javascript Pin
shampoo7225-Oct-20 7:04
Membershampoo7225-Oct-20 7:04 
GeneralRe: XML NodeList Java object showing null in Nashorn Javascript Pin
Richard MacCutchan25-Oct-20 7:14
mveRichard MacCutchan25-Oct-20 7:14 
AnswerRe: XML NodeList Java object showing null in Nashorn Javascript Pin
shampoo7225-Oct-20 17:36
Membershampoo7225-Oct-20 17:36 
QuestionGetting a video webm from client to server Pin
Rayj201023-Oct-20 10:58
MemberRayj201023-Oct-20 10:58 
Questionimport declarations may only appear at top level of a module Pin
jkirkerx19-Oct-20 10:38
professionaljkirkerx19-Oct-20 10:38 
AnswerRe: import declarations may only appear at top level of a module Pin
jkirkerx19-Oct-20 11:16
professionaljkirkerx19-Oct-20 11:16 
QuestionGetting a textbox in another frame Pin
jkirkerx18-Oct-20 13:18
professionaljkirkerx18-Oct-20 13:18 
Answer[abandon] the idea Pin
jkirkerx19-Oct-20 10:29
professionaljkirkerx19-Oct-20 10:29 
AnswerRe: Getting a textbox in another frame Pin
DerekT-P19-Oct-20 10:46
professionalDerekT-P19-Oct-20 10:46 
GeneralRe: Getting a textbox in another frame Pin
jkirkerx19-Oct-20 11:12
professionaljkirkerx19-Oct-20 11:12 
QuestionVirtual populate in JS Pin
adids122123-Sep-20 2:38
Memberadids122123-Sep-20 2:38 
QuestionSetting max length property of masked input control in ember js Pin
simpledeveloper22-Sep-20 6:45
Membersimpledeveloper22-Sep-20 6:45 
AnswerRe: Setting max length property of masked input control in ember js Pin
ZurdoDev22-Sep-20 7:07
professionalZurdoDev22-Sep-20 7:07 
QuestionNeed to mask Alphanumeric values with some special characters allowed Pin
simpledeveloper9-Sep-20 11:02
Membersimpledeveloper9-Sep-20 11:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.