try this:
$('a[href^="mailto"]').on('click',
function() {
return confirm('Do you want to send email?');
});
質問
Is there a way with javascript to automatically have the page look for any mailto links and then have it fire off an confirm dialog when a user clicks on the mailto link?
From this site I found a way to do so for an alert. I am beyond a novice with javascript.
We need to warn people not to include confidential information in the their email without having an existing relationship.
HTML:
<a href="mailto:name@domain.com">Email Link</a>
Javascript:
$('a[href^="mailto"]').on('click',
function() {
alert('This is some alert text');
});
解決 2
try this:
$('a[href^="mailto"]').on('click',
function() {
return confirm('Do you want to send email?');
});
他のヒント
There is a confirm
function in javascript.
$('a[href^="mailto"]').on('click',
function() {
if (!(confirm('This is some alert text'))) {
return false;
}
});
You can use javascript confirm dialog
$('a[href^="mailto"]').on('click', function() {
return confirm('your question');
});
you can make it a one liner without jquery:
<a href="mailto:name@domain.com" onclick="return confirm('Are you sure?')">Email Link</a>