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

182
Views
notfication won't show up after form submission

i wrote a simple html page in order to test JavaScript notification API but for some reason when i want to submit the form to trigger the notification, it wont appear and the browser keeps asking me permission to allow notification, can someone tell me why the notification doesn't appear?

the code is as follows:

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>testing notification</title>

</head>
<body>
<form id="myform" name="meForm" method="post" action="#">
    <input type="text" name="para"><br>
    <input type="text" name="para2"><br>
    <select name="location" id="selLocation">
        <option value="Sunnyvale, CA">Sunnyvales</option>
        <option value="Los Angeles, CA">Los-Angeles</option>
        <option value="Mountain View, CA">Mountain Views</option>
        <option value="">China</option>
        <option>Australia</option>
    </select><br>
    <input type="submit" name="submitButton" id="sub">
</form>
<script type="text/javascript" >
    const form=document.querySelector("#myform");
    Notification.requestPermission().then((permission)=>{
        console.log('the permission is ' , permission)
    });
    form.addEventListener("submit", (event)=>{
        //event.preventDefault()
        let not=new Notification("hey",{
            body:"you submitted the form successfully"});
        setTimeout(()=>{
            not.close()},5000)
    });
</script>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Mozilla Docs on Notification API

This feature is only available in secure contexts, so you have to test it on a domain with https enabled

But your code is just fine and should work as expected

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!