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

144
Views
I want to add the name of my mailbox at the top of my page but it shows and goes off

I want to add the name of my mailbox at the top of my page but it shows for few seconds and goes off.

What I want is for e.g. INBOX to show at the top of the page, then all the inbox mails will be below the title.

The INBOX shows for nanoseconds and then my inbox mails load and overshadows it.

How can I resolve this?

function load_mailbox(mailbox) {
  // Show the mailbox and hide other views
  document.querySelector('#emails-view').style.display = 'block';
  document.querySelector('#compose-view').style.display = 'none';
  document.querySelector('#content-view').style.display = 'none';

  //Show the mailbox name
  document.querySelector('#emails-view').innerHTML = `<h3>${mailbox.charAt(0).toUpperCase() + mailbox.slice(1)}</h3>`;

  // display details of mailbox
  let output = '';

  // using get request to retrieve details
  fetch(`/emails/${mailbox}`)
    .then(response => response.json())
    .then(emails => {
      emails.forEach(email => {
        //display subjecct, sender and timestamp of mail
        output += `<div class="mail" onclick="viewEmail(${email.id}, ${mailbox})">
                    <button class="btn pr-5" style="min-width: 120px; display: inline-block;">${email.sender}</button> 
                    <button class="btn">${email.subject}</button>
                    <button class="badge float-right">${email.timestamp}</button> 
                    <span class="list-group-item"></span> 
                  </div>`;
      })
      //add to html emails view
      let emailList = document.querySelector('#emails-view');
      emailList.innerHTML = output;
    });


}
<div id="emails-view">
</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your mailbox name is being overwritten as soon as your fetch request is processed.

You have two options.

  1. Append the response to the name in one div
  2. Use a separate div for the name and another div for the response.

#2 is far more preferable.

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!