Javascript examples for String Operation:String URL
Use File name extension to MIME type
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//www.j a va2 s.c o m Object.prototype.gif = 'gotcha'; (function() { var extToMimes = { 'img': 'image/jpeg', 'png': 'image/png' } window.getMimeByExt = function(ext) { return extToMimes[ext]; } })(); document.body.innerHTML = getMimeByExt('gif'); } </script> </head> <body> </body> </html>