Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
Why is the return statement underlined in onclick confirm method (VsCode)?

I want to give a confirm to the screen before deleting the object, but the return statement is constantly being underlined.How can I fix that?

{% if notifications %}
{% for not in notifications %}
        <li>
            <figure><img src="{{not.object.image.url}}" alt=""></figure>
            <small>{{not.object.category.name}}</small>
            <h4>{{not.object.title}}</h4>
            <p>{{not.message}}</p>
            <!-- <p><a href="#0" class="btn_1 gray"><i class="fa fa-fw fa-eye"></i> View course</a></p> -->
            <ul class="buttons">
                <li><a onclick="return confirm('Are you sure?');"  href="{% url 'deleteNotificationsAdmin' not.pk %}" class="btn_1 gray delete wishlist_close" >
                    <i class="fa fa-fw fa-times-circle-o"></i> Delete</a></li>
            </ul>
        </li>
{% endfor %}
{% endif %}

When I hover over it with the mouse it gives an error

A 'return' statement can only be used within a function body.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So it turns out A 'return' statement can only be used within a function body. error is actually a bug in Visual Studio Code and currently scheduled to be fixed in March 2022 Milestone.

And according to HTML 5.2: 7.4, it is valid to use return value with event handlers.

Process return value as follows:

  • If the event type is mouseover

  • If the event type is error and E is an ErrorEvent object

    • If return value is a Web IDL boolean true value, then cancel the event.
  • If the event type is beforeunload

    • NOTE: The event handler IDL attribute’s type is OnBeforeUnloadEventHandler, and the return value will therefore have been coerced into either the value null or a DOMString.

    • If the return value is null, then cancel the event.

    • Otherwise, if the Event object E is a BeforeUnloadEvent object, and the Event object E’s returnValue attribute’s value is the empty string, then set the returnValue attribute’s value to return value.

  • Otherwise If return value is a Web IDL boolean false value, then cancel the event.

As a workaround, you can disable html.validate.scripts option from Visual Studio Code settings.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda