Reputation: 23
This is my code idk where am wrong pls help!
https://codepen.io/visa2code/pen/oNojdRr
<a class="getstarted" href='javascript:my()'> <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" class="bi bi-box-arrow-in-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M6 3.5a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-2a.5.5 0 0 0-1 0v2A1.5 1.5 0 0 0 6.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-8A1.5 1.5 0 0 0 5 3.5v2a.5.5 0 0 0 1 0v-2z" />
<path fill-rule="evenodd" d="M11.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H1.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg></i> Login</a>
The thing i placed in script tag
function my() {
Swal.fire({
icon: 'info',
title: 'Do you agree to our terms and ads policy?',
text:'<a href="/terms">Terms</a> and <a href="/ads-policy">Ads Policy</a>,
footer: 'Copyright 2022 © Cryptons API - All right reserved.'
}).then((result) => {
if (result.isConfirmed) {
window.location.href = '/auth/discord/login';
} else if (result.isDenied) {
window.location.href = '/';
}
})
}
The error i get
Uncaught ReferenceError: my is not defined
The script tag is placed in the <head>
tag
Upvotes: 0
Views: 49
Reputation: 41
I think it'll be better if you use onclick for calling functions in tags
<a class="getstarted" onclick='my()'>
Upvotes: 1
Reputation: 903
try this:
function my() {
Swal.fire({
icon: 'info',
title: 'Do you agree to our terms and ads policy?',
text:'<a href="/terms">Terms</a> and <a href="/ads-policy">Ads Policy</a>',
footer: 'Copyright 2022 © Cryptons API - All right reserved.'
}).then((result) => {
if (result.isConfirmed) {
window.location.href = '/auth/discord/login';
} else if (result.isDenied) {
window.location.href = '/';
}
})
}
Upvotes: 0