My thing is that "The system needs to ask the user that" are you going to open the image or upload it.? "using the confirmation window. If the user clicks" okay ", we should not prevent the default action for this anchor tag, let it go, but if the user clicks on cancel, then a specific image must be loaded ...
HTML:
<a href="http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=3c6263c3453b">test</a>
JS:
$('a').click(function (e) {
if (!$(this).is('[download]')) {
var cond = confirm('Press ok to view, cancel to save..');
if (!cond) {
e.preventDefault();
$(this).attr('download', 'download').click().removeAttr('download');
}
}
});
Can anyone tell how to achieve this?
source
share