Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!