-2

I have header with different links to subsections of my webapp:

    <div class="collapse navbar-collapse" id="navbarSupportedContent">

      <!-- Left -->
      <ul class="navbar-nav mr-auto">
        <li class="nav-item active">
          <a class="nav-link waves-effect" href="{{ url_for('homepage') }}">Home
            <span class="sr-only">(current)</span>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link waves-effect" href="{{ url_for('dashboards') }}" target="_blank">Dashboards</a>
        </li>
        <li class="nav-item">
          <a class="nav-link waves-effect" href="{{ url_for('support')}}" target="_blank">Support</a>
        </li>
      </ul>

    </div>

While home will always open in the same tab, any other navbar item opens as new tab. how to prevent it? All of the below templates extends header.

@app.route('/')
def homepage():
    return render_template('mainpage.html')

@app.route('/dashboards/')
def dashboards():
    return render_template('dashboards.html', 
        labels=sample_data.index, 
        data=sample_data['Resource ID'], 
        max_instances=max_instances, 
        running_instances=running_instances)

@app.route('/support/')
def support():
    return render_template('support.html')
davidism
  • 121,510
  • 29
  • 395
  • 339
Bartek Malysz
  • 922
  • 5
  • 14
  • 37

1 Answers1

1

It's not flask problem/question, but pure html. Part of your a tags have target="_blank". Remove target attribute if you want them to open in the same tab. Have a look at https://www.w3schools.com/tags/att_a_target.asp for more info.

buran
  • 13,682
  • 10
  • 36
  • 61