Here's my javascript:trendoman wrote: Welcome
Could you post full JS script to make this solution complete?
- Code: Select all
<script type="text/javascript">
function DownloadAndRedirect()
{
//Clicked link goes here
var file = "<cms:show download_link/>";
// Url for redirect
var redirectUrl = "/redirect.php";
// Make a form with hidden input
var form = $('<form action="' + redirectUrl + '" method="post" >' +
'<input type="hidden" name="file" value="' + file + '"/>' +
'</form>');
// Attach this form to body and submit it
$('body').append(form);
form.submit();
}
</script>
And the download button:
- Code: Select all
<a style="border-radius:4px;padding: 20px;" class="btn btn-success btn-lg btn-block" href="javascript:DownloadAndRedirect()"><i class="fa fa-download" aria-hidden="true"></i> Download</a>
Finally here's the redirect download button target:
- Code: Select all
<cms:set file = "<cms:gpc 'file' />" />
<cms:if file >
<span style="text-decoration:none" class="btn btn-success">
<a style="color:white;text-decoration:none" href="<cms:show file />" target="_blank" ><i class="fa fa-download" aria-hidden="true"></i> Download File</a>
</span>
<cms:else />
<span type="button" class="error-button disabled">No file detected</span>
</cms:if>
Right now, I didn't make auto redirect after downloading like i use before, i think its not neccesary. Now, its just directly to redirected page without downloading. So, the download button is on the destination page.