Donwnload link not working for some browsers

hi was doing some testing i found out download link isnt working for IE browser and opera mini browsers

<form class="form-horizontal" name="action" action="" method="post">
<input type="hidden" name="csrftoken" value="{_CSRFTOKEN}">

<div><a id="link" href="{SONG_URL}" download hidden></a></div>	

<div><button onclick="document.getElementById('link').click()" class="h4 btndownload">
	<i class="fa fa-arrow-circle-o-down i-lg"></i>


 <input type="hidden" name="action" value="update">

please what am i doing wrong? thanks

Hi @skyhighweb, I don’t have either browser at hand, but one thing to note is that since a button defaults to type="submit", there will always be a race condition between triggering the download link click and submitting the form… so maybe try adding type="button" (which would probably be a good idea anyway).

But why the button in the first place… can’t you just display the regular link?

hi thanks for the reply its connect to the server to update a table and since am not using ajax its clicking the button reloads the page and pops the dialog to download but for IE it just reload same with operas browser

ps i added the type button it opens the dialog but page doesnt reload so server side doesnt get updated

What are the HTTP headers being returned for the file?

Well that suggest that executing JS while leaving the page does indeed not work in IE (also note that you don’t necessarily get a dialog, depending on your browser settings).

Then wouldn’t it be possible to also serve the desired file with the script that updates the table? I’d definitely use AJAX here though to avoid that (probably rather unexpected) reload.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.