Initiate download without iframe - javascript

I'm looking to initiate a download in a webpage using either JavaScript or PHP. All of the examples I've seen use an iframe to load the source of the file. Unfortunately this method doesn't seem to work with all smartphone browsers, specifically my Samsung Galaxy S3. It seems to be a known issue with some of Android's stock browsers.
I cannot use a link because the download must happen auto-magically, and using document.ready or window.load to initiate a window.location call is not acceptable because even though the download initiates it stops all the JS functionality on the current page. I have some JavaScript that must run after the download has initiated.
Basically the flow is:
Show JavaScript progress bar to simulate download progress
Initiate download in background
Once progress bar finishes -> jquery.show new content on page (installation instructions)
Can't seem to find a cross-browser solution that will let me get through all 3 steps above.

Related

Downloading Silently by Chrome Extension

I need my extension to bulk download assess in a web page.
I set saveAs:false for chrome.downloads.download so that I do not get saveAs dialog. But when download starts, download bar at the bottom of the browser gets opened and all list of downloads puts into it. This clutters the download bar and Chrome interface.
Is it possible to prevent download bar from opening and not put the downloads that are started by an extension?
It's possible to hide the download bar (called shelf in Chrome UI lingo) completely, but not filter out specific downloads.
chrome.downloads.setShelfEnabled(false); // requires "downloads.shelf" permission
You can clear out your downloads from the download list with chrome.downloads.erase method.
Consider an alternative (if more technically challenging) approach of "downloading" through XHR to a temporary HTML5 FileSystem, forming an archive file, and then calling chrome.downloads on that. May not work if you need all the files immediately unpacked.

Flash in Gmail File Upload Progress Bar

Several resources I have found claim, that GMail File Upload incorporates Flash to display progress bar or to allow multiple file uploads.
For example:
http://anders.com/cms/290
http://www.neowin.net/news/gmail-enables-multi-attatchment-uploading
My question is, it true, that GMail uses Flash to generate upload Progress Bar? If not, how does GMail achieve Progress Bars in IE9, which does not support FileAPI? I did several tests, and I was not able to confirm presence of Flash during GMail File Upload process:
I installed FlashBlocker which was blocking Flash content effectively. However, GMail File Upload progress Bar was not blocked.
I right clicked on the Progress Bar to see if it is Flash applet, but no it is not.
I checked source code, but I did not find any reference to .swf code.
So how does the GMail imlement its File Upload, which is displayed in all the browsers including IE9?
Any idea, please, if another developers can achieve the same results, or if the File Upload Progress Bar is Google specific?
I know there are many plugins available for Google Upload, but I wish to have clean JavaScript, HTML5, PHP, CSS3 and compatibility with IE9. I am therefore willing to code all the code on my own, if I understand the subject.
I use the following tools:
Javascript
HTML5
PHP
MySQL
CSS3
Thank you.
Update:
It really looks that GMail uses Flash to calculate Progress percentage when uploading a file. It than uses CSS to generate progress bar, therefore no Flash applet is used to display the Progress Bar.
I discovered this by disabling Flash in IE9. In contrast to Chrome, Flash can be easily disabled in IE 9.
Please, if you have anything to add to this topic, I will gladly discuss. For example, it would be interesting to know, how Flash applet can generate file upload progress percentage, and how it than can communicate that information with JavaScript or CSS.
I have further explored, and I have to confirm, YES, still today, GMail must use several Flash objects that support file/attachment upload.
It is difficult to disable Flash in Chrome. However, it can be disabled in IE. After disabling flash in IE, GMail has switched to another, less interactive upload system without progress bars.
This is a clear proof of that GMail still uses Flash to support its upload routines.
Google switched to HTML5 multi-file uploads about 2 years ago. I think they use fallback flash uploaders.
http://www.webmonkey.com/2010/04/google-turns-to-html5-for-gmails-new-drag-and-drop-attachments/
This Library (jQuery File-Upload - Demo here: http://blueimp.github.com/jQuery-File-Upload/) claims that it can use the File Progress of Internet Explorer (at least some way ;-)):
All versions of Internet Explorer will also update the global progress
bar after each iframe based upload. However since IE does not report
the file size, the global progress bar will measure each uploaded file
the same without regard to the size of the uploaded file.
https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support

Is it possible to obtain the download progress of an dynamically loaded javascript file?

I'd like to load a basic homepage for a web-app which asynchronously loads a large javascript file (the guts of the application).
Can I retrieve the download progress of this js file?
I would like to display a loading bar that accurately reflects the download progress, then when the script has finished enable a 'launch' button.
I normally use jquery but am happy for any solutions! I'll be using a php backend if that helps.
This won't work on all browsers, but you can use the <progress> tag in HTML5.
http://blog.greweb.fr/2012/04/work-in-progress/
You can also use the progress event for the connection.
https://developer.mozilla.org/En/Using_XMLHttpRequest#Monitoring_progress

Getting file upload status without AJAX

It seems to me if information is already being output to a user by a browser it ought to be accessible in the DOM in some manner via javascript. When you upload a file using a webkit browser (and possibly others) using the good old iframe trick the browser displays an upload percent in the status bar at the bottom of the browser window. It would be pretty amazing to be able to tap into that instead of needing to query the server for that same information. Has anyone ever tried to do so?
I have try something like this. If using old method with iframe for uploading files you can get upload information only if you have APC enable on server side (for php). With javascript the maximum that you can know is the start and the end of the upload (by using iframe onload event). So you can use an animated gif when file upload start and remove the animated gif when it ends (that causes the onload event of the iframe).
Then after upload iframe will contain any errors message of the upload status. You can do some more trick by returning file info as JSON when upload finish.

Javascript stops working with HTML5 manifest file

So I created this iphone webapp using an HTML5 manifest file to be able to open it offline. The problem is that the 2 javascript files I load stop working as soon as I openthe appin fullscreen mode twice. Let me explain:
it works when you reload it in ios safari
in webapp mode it works fine the first time you open it
the 2e time you open it the javascript loads but does not work. (it intercepts clicks and does that, only the next page doesn't load with ajax the 2e time)
any idea how this is possible. Must i somehow "reset" the javascript file?
I use jquery (first file) and my js file.
When you are loading the second page with ajax, the url for that page must be included in the cache.manifest.
You probably also want to setup your phone to go through a proxy like Charles http://www.charlesproxy.com/ This will let you see any files that are loaded by the site.
We ran into issues where files were being loaded with cache-busters at the end of the url. Since the cache-busters changed the url, they didn't exactly match what was in the cache.manifest.

Categories