So I asked this question a while ago and it got immediately closed so I'll give more detail the issue seems to be specific to the dmg file type I've never encountered the problem till now.
I simply want to be able to click a button and then have the dmg downloaded without using much javascript or any.
However using my code the dmg file opens in the browser so you get a bunch of binary gibberish and the file doesn't download if you want to see what I mean head to https://lucas-testing.000webhostapp.com/release then click download for MacOS.
The dmg's file name changes as the version number is part of the name so I use php to get the file information and create a variable storing that website address for example the current link generated by my PHP would be:
var downloadLinkAlt = "https://lucas-testing.000webhostapp.com/release/The City Of Truro Mariners - Management Console-1.0.19.dmg"
My code to then download this link is:
<button onclick="location.href=downloadLinkAlt" id="DownloadByOSAlt" class="btn btn-sm btn-primary mt-3">Download for MacOS</button>
I know for a fact the above code works as it works perfectly with the exact same link but with an exe file extension instead.
Things I have tried:
The download attribute that can be used in HTML5 to force download things like PDF's:
<button onclick="location.href=downloadLinkAlt" id="DownloadByOSAlt" class="btn btn-sm btn-primary mt-3" download>Loading...</button>
Reference: https://www.w3schools.com/tags/att_a_download.asp
Putting the button in a form and using a get request with the link:
<form method="get" action=downloadLinkAlt>
<button type="submit">Download!</button>
</form>
Reference: https://stackoverflow.com/a/11620761/12887221
Using an invisible iframe that's source is changed when the button is pressed:
document.getElementById('my_iframe').src = downloadLinkAlt;
<iframe id="my_iframe" style="display:none;"></iframe>
Reference: https://stackoverflow.com/a/22231021/12887221
Does anyone have any suggestions as to what to try next?