Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
197
rated 0 times [  200] [ 3]  / answers: 1 / hits: 30193  / 12 Years ago, tue, april 17, 2012, 12:00:00

Hello everyone,



I've tried to retrieve an image from a websocket server (in .NET)
I send the image as bytes then I retrieve it on the client side,
the code for retrieving on the client side (using canvas and JavaScript):



var c=document.GetElementById(myCanvas);
var ctx=c.getContext(2d);
ws.onmessage=function(evt)
{
var image=new Image();
image.src=URL.createObjectURL(evt.data);
ctx.drawImage(image,0,0);
}


it perfectly displays the picture on firefox,
but at Chrome, it just returning undefined and won't load the image through createObjectURL
I'm using Chrome 18.0.1025.162



any idea?


More From » html

 Answers
13

From MDN:




This method is prefixed in Chrome and Webkit as window.webkitURL.createObjectURL().




You should test if URL exists and then use the appropriate object:



(window.URL ? URL : webkitURL).createObjectURL(evt.data);

[#86190] Monday, April 16, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
clarkulisesa

Total Points: 422
Total Questions: 93
Total Answers: 112

Location: Austria
Member since Thu, Jan 7, 2021
3 Years ago
clarkulisesa questions
Mon, Feb 24, 20, 00:00, 4 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;