Prevent submit action to avoid side effects (#328)

Otherwise the download is blocked and a `/?format=gpx#` query is added to the URL in Chromium.
This commit is contained in:
Norbert Renner 2020-08-04 11:13:24 +02:00
parent c3ac8345ee
commit a1af69a44c

View file

@ -41,7 +41,7 @@ BR.Export = L.Class.extend({
} }
}, },
_export: function() { _export: function(e) {
var exportForm = document.forms['export']; var exportForm = document.forms['export'];
var format = exportForm['format'].value || $('#export-format input:radio:checked').val(); var format = exportForm['format'].value || $('#export-format input:radio:checked').val();
var name = encodeURIComponent(exportForm['trackname'].value); var name = encodeURIComponent(exportForm['trackname'].value);
@ -49,6 +49,8 @@ BR.Export = L.Class.extend({
var uri = this.router.getUrl(this.latLngs, this.pois.getMarkers(), format, name, includeWaypoints); var uri = this.router.getUrl(this.latLngs, this.pois.getMarkers(), format, name, includeWaypoints);
e.preventDefault();
var evt = document.createEvent('MouseEvents'); var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var link = document.createElement('a'); var link = document.createElement('a');