Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
HTML not reading JavaScript function in <script> tag

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> &nbsp; &nbsp; 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 &copy 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

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I think it'll be better if you use onclick for calling functions in tags

<a class="getstarted" onclick='my()'> 
about 4 years ago · Juan Pablo Isaza Denunciar

0

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 &copy Cryptons API - All right reserved.'
    }).then((result) => {
  if (result.isConfirmed) {
    window.location.href = '/auth/discord/login';
  } else if (result.isDenied) {
   window.location.href = '/';
  }
})
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda