Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  16] [ 6]  / answers: 1 / hits: 19858  / 13 Years ago, mon, september 26, 2011, 12:00:00

I would like to use createElement(img') to create .jpeg extension instead of .png



According to Flanagan's book JavaScript: The Definitive Guide: Activate Your Web Pages By David Flanagan,




For jpeg image type, the second argument should be a number between 0
and 1 specifying the image quality level.




I am not sure what the syntax for the code would be.



Is it something like this?



createElement(img,1)

More From » jquery

 Answers
18

The book is talking about html5's canvas tag and specifically its .toDataURL method.



I think you want to do something like:



var img = document.createElement('img');
img.src = 'myImageSource.jpg';


In this case, it's up to the web server to deliver the image and its type information to the web browser.


[#89909] Sunday, September 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brendaw

Total Points: 508
Total Questions: 90
Total Answers: 100

Location: Maldives
Member since Sat, Jan 29, 2022
2 Years ago
;