I have a "Download file" href defined in my javascript file as:
$("#downloadTag").html("Download");
In chrome it works as expected i.e. when I click on this download link it gives file name as "download.csv". However, in firefox, it puts some gibberish name like "puzdb.part".
Could someone please point me what I am doing wrong?
Thanks
Edit:
Here is the jsfiddle demo: http://jsfiddle.net/kLJz9/
Edit #2:
I noticed that on windows it does not put .csv extension for chrome as well and behavior for firefox is still same (i.e. .part extension)
For Chrome you can designate the file name/extension by adding a download attribute to your anchor tag.
Download
This attribute only works in chrome v 14+ and no other browser.
I am also looking for a solution to this problem, but I hope this helps.
EDIT:
the download attribute should fix the issue you are having on windows machines and chrome.
Related
I've a shared directory reachable by html page in this way
<div onclick="windows.open('file://mypath/mysharefolder','_blank');">Shared folder</div>
This works with internet explorer, but not with Chrome browser (error: Not allowed to load local resource).
So I've thought of replacing the link with a tag to allow the download of a lnk file (created manually) containing the path of the shared directory like this
<a href="mylinktofolder.lnk" download>Shared folder</a>
this tag works to download other kind of file (img,pdf,...), but not with lnk file; download in Chrome fails because doesn't find file mylinktofolder.download.
Is it possible to download such a file?
Thanks in advance
Chrome marks .lnk files as unsafe for download so you won't be able to workaround this using html/js unfortunately
Sources:
https://stackoverflow.com/questions/55177641/lnk-file-downloading-as-download-in-chrome-and-it-failed-to-download-in-first\
https://stackoverflow.com/a/34890432/2491027
Is it possible to download such a file?
Yes, sort off, here I show two tabs but the second is as you described a shared folder that was opened as second tab, however, has been torn off to show the two types of links in the first index.html
So to answer your question the second link tested with a range of LNK files lastly to a cmd.exe.lnk and onclick triggers a lnk download but as normal for windows the .lnk extension is not shown as actioned, so if the lnk is
a file like svg.lnk it will open the linked svg in the second tab.
a lnk to a folder it will open the folder
a lnk to a command it in turn forces cmd.exe to be downloaded with a warning
and you can accept (keep) and run that copy of cmd !
All the above is possible using Chrome based browsers such as Edge or SlimJet or Ungoogled Chrome. and Chrome too.
<div onclick="window.open('file://c:/mysharedfolder','_blank');">Shared folder</div>
<div onclick="window.open('file://C:/myshortcuts/downloads.lnk','_blank');">downloads.lnk</div>
.
As non admin user I can navigate to local shares or remoteshares or remote mapped drives without any authorisation, other than I have user read write permission for all those locations.
<div onclick="window.open('file://C:/TEMP/HTA/share(local).lnk','_blank');">Local Shared folder</div>
Okay, here's a weird issue for you guy sand gals.
I'm using a window.open tag in JS to open a .cfm file that will open in Excel (Report), however, the appended URL variable appears to change. It seems that the ? gets changed to an _ and thus the browser thinks its a text file and not a web page. Any Ideas??
window.open("amal_reports/rpt_change_indicator_notes.cfm?batch="+selBatch);
The URL should be
http://example.com/amal_reports/rpt_change_indicator_notes.cfm?batch=1160 but when the browser asks what do with the file it says
rpt_change_indicator_notes_cfm_batch=1160 and wants to open a text
file.
If I call the report directly in the URL without the form or JS stuff the same thing happens, conversely, if I remove the URl variable (?batch=1160) the report opens in Excel as expected but no data is populated because the batch number is missing.
So, to summarize, the browser is changing my .cfm link from js or directly in the browser to _cfm and thus it won't open in Excel as expected.
Okay, developer error! It looks as though checking the developers tool (F12) based upon theGleep suggestion, I found that my page was missing or couldn't find a variable. Once that was corrected the report open as expected.
the chrome dev tool gives me a error. actually i'm trying to get an http ressource from an https webpage :
i don't know where these files are called to change the target. i guess we can know with the chrome dev tool but can't find how. i would like to know which file is firing the call, which line... (if i get only the filename, it's fine)
someone can help ?
The blue box in the picture below represents the link to the exact line that caused the error. The format is filename:XX, where filename is the name of the file where the script originated, and XX is the line of code within that file.
Click the link to see that line of code in the Sources panel. If the file is minified, click the Format button to pretty-print it.
I need to allow users to click a link to a .bat file on an IIS 6.0 server directory and view that file as plain text. I have set the MIME type for .bat file to "text/plain." This works perfectly in both Chrome and Firefox. The way this works is that I have a button that launches a separate popup browser window to the .bat file. Example is below:
onclick=\"window.open(\'\/eemcontrolpanel\/jobs\/" + encodedFileName +"\',\'popUpWindow\',\'height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes\');\">View Script</button>").scrollHeight;
As I said, this works in both Chrome and Firefox, but for some reason, IE 8 immediately closes the popup and asks me if I want to Run or Save the file.
I think IE goes by filename extension to detect its an executable file. Maybe you could give it another name by adding a header like:
'Content-Disposition: attachment; filename="thebat.txt"'
Saw a similar question at Download a file using Javascript but this one is specific to IE and I'm using extjs and alfresco (opsoro). I can get a download prompt for text files fine in Opera, Chrome, and Firefox, but not IE.
Below is a list of what I've tried so far, which all work on other browsers except IE7.
document.location = downloadLocation;
window.open(downloadLocation,'Download');
location.href = downloadLocation;
When downloading other mimetypes (csv, xls), they download fine using any of the methods mentioned above.
You may need some help from the backend. Instead of serving the file statically, the backend app can load and serve the file contents with a content disposition header. That is guaranteed to invoke a download.
Content-disposition: attachment; filename=hello.txt
I don't know how you could do it with Alfresco, though.
Edit: Wait! Check this out: http://forums.alfresco.com/en/viewtopic.php?f=36&t=21356&p=70252