How to enable JavaScript API files in IE8

I developed a web application in asp.net, in this project there is a page in which the user must select a file in the image format (jpeg, jpg, bmp, ...), and I want to view the image on the page but I do not want to publish the file on server. I want to process it on the client. I did this using java script functions through the API files, but it only works in IE9, but most users use IE8, the reason is that IE8 is not a file support API, is there any way to update IE8 or some corrections in the code behind, I mean, check if the browser is IE, and does not support the API file API, which automatically updates IE8 to IE9.

I do not want to ask the user to do this in the message. I want to do this programmatically!
even if you can install the special patch needed for the file API because the clients thought it was a mistake in my application and their computer knowledge was low, what should I do with it?
I also use Async File Upload Ajax Control. But it sends the file to the server in any way using the ajax solution and the HTTP handler, but java scripts do all this in the client’s browser.

after the script checks the browser supports the API or not

<script> if (window.File && window.FileReader && window.FileList && window.Blob) document.write("<b>File API supported.</b>"); else document.write('<i>File API not supported by this browser.</i>'); </script> 

The following scripts read and download the image.

 function readfile(e1) { var filename = e1.target.files[0]; var fr = new FileReader(); fr.onload = readerHandler; fr.readAsText(filename); } 

HTML code:

 <input type="file" id="getimage"> <fieldset><legend>Your image here</legend> <div id="imgstore"></div> </fieldset> 

JavaScript Code:

 <script> function imageHandler(e2) { var store = document.getElementById('imgstore'); store.innerHTML='<img src="' + e2.target.result +'">'; } function loadimage(e1) { var filename = e1.target.files[0]; var fr = new FileReader(); fr.onload = imageHandler; fr.readAsDataURL(filename); } window.onload=function() { var x = document.getElementById("filebrowsed"); x.addEventListener('change', readfile, false); var y = document.getElementById("getimage"); y.addEventListener('change', loadimage, false); } </script> 
+6
source share
3 answers

You cannot install anything special to add support for API files in IE8. You can use polyfill to implement this function in browsers that do not support it. Take a look at this HTML5 Cross Browser Polyfills list (you should find something suitable for you in the File API / Drag and Drop section).

+10
source

After some research that I have, there is no way to enable the API in IE8, but I got something that I want to share with you .....
Not directly, HTML 5 is not supported by IE8. There are add-ons for Canvas, and there is also Google Chrome Frame, a plugin for adding HTML 5 in IE older than 9.
As I understand it, Google Chrome Frame is a great way to use HTML5.
It increases IE speed 10 times, and is also very easy to use, and I describe it for all of you ... Google Chrome Frame

A plug-in for Internet Explorer that adds Microsoft browser, full HTML 5 support and a JavaScript compiler in Chrome! A stable version was released on September 22, 2010, and many sites added code to their pages.

This plugin will work in Internet Explorer 6, 7 and later. Google wants to break the barrier that prevents the Web from evolving: the most common browser and its lack of compatibility with new standards.

When it is recognized, Internet Explorer will run under WebKit, the Chrome and Safari rendering engine, and it will use the ultra-fast JavaScript compiler in return if the interpreter is IE.

The advantage of this plugin is great for web application compatibility and will be even more useful with WebGL integrated into Webkit, which allows us to use 3D applications in a browser: a completely different Web! WebGL is also supported by Firefox since version 3.7.

Since May 2011, the plugin can be installed without administrator rights, so in the old version of IE, which are included in the server and cannot be updated.

A message appears in the web page code tag asking you to download the plugin. After installing it, IE launches as Chrome and will support HTML 5.

Frame features

Off-line mode. And tags. Microsoft also plans to implement them in IE. Canvas. WebGL. CSS 3. JavaScript compiler. Acid Compatibility 3. Watch the video.

Microsoft reaction

We expected that Microsoft did not really appreciate this initiative, which promotes HTML 5 to the detriment of their own Silverlight solution. The company emphasizes the security issue:

Given the security problems with plugins in general and Google Chrome in particular, Google Chrome Frame works as a plugin, doubled the attack zone for malware and malicious scripts.

**

Chrome Frame. Automatic installation. β†’ http://www.google.com/chromeframe/?quickenable=true
Google Chrome code frame. β†’ https://developers.google.com/chrome/chrome-frame/
Chrome Frame: Developer's Guide. β†’ http://www.chromium.org/developers/how-tos/chrome-frame-getting-started

**

+2
source

This works for me in pre IE10, I use https://github.com/eligrey/FileSaver.js for any other browser, note that this does not work perfectly because it is IE and you know well what I mean

Hope this helps

 /** * saves File, pops up a built in javascript file as a download * @param {String} filename, eg doc.csv * @param {String} filecontent eg "this","is","csv" * @param {String} mimetype eg "text/plain" */ function saveAs (filename, filecontent, mimetype) { var w = window.open(); var doc = w.document; doc.open( mimetype,'replace'); doc.charset = "utf-8"; doc.write(filecontent); doc.close(); doc.execCommand("SaveAs", null, filename); } 
+2
source

Source: https://habr.com/ru/post/923845/


All Articles