JavaScript How to navigate to specific tab of bootstrap 4 from external link

I want to open a specific tab of bootstrap 4 from external page link .

Page 1: nav.html I want to go from this page one to second page

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

<a target='_blank' href="index.html#tab-1">tab 1</a>
<a target='_blank' href="index.html#tab-2">tab 2</a>
<a target='_blank' href="index.html#tab-3">tab 3</a>


 <script src="assets/js/jquery-3.3.1.min.js"></script>
 <script src="assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

Page 2: index.html this page where I want to open specific tab

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>tab</title>
    <link rel="stylesheet" target='_blank' href="assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" target='_blank' href="assets/css/styles.css">
</head>

<body>
    <div>
        <ul class="nav nav-tabs">
            <li class="nav-item"><a class="nav-link active" role="tab" data-toggle="tab" target='_blank' href="#tab-1">Tab 1</a></li>
            <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" target='_blank' href="#tab-2">Tab 2</a></li>
            <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" target='_blank' href="#tab-3">Tab 3</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" role="tabpanel" id="tab-1">
                <p>Content for tab 1.</p>
            </div>
            <div class="tab-pane" role="tabpanel" id="tab-2">
                <p>Content for tab 2.</p>
            </div>
            <div class="tab-pane" role="tabpanel" id="tab-3">
                <p>Content for tab 3.</p>
            </div>
        </div>
    </div>
    <script src="assets/js/jquery.min.js"></script>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
</body>

</html>

I use bootstrap 4 in my page.

Answer:1

You just need to add this code to the bottom of the index.html page:

<script>
    jQuery(document).ready(function ($) {
        let selectedTab = window.location.hash;
        $('.nav-link[target='_blank' href="' + selectedTab + '"]' ).trigger('click');
    })
</script>
Answer:2

When i run console.log (f ()) i want it returns the data that came from getData (url), but it keeps returning Promise {<pending>}. I thought using await keyword would solve this by making the ...

When i run console.log (f ()) i want it returns the data that came from getData (url), but it keeps returning Promise {<pending>}. I thought using await keyword would solve this by making the ...

Is it possible to mark (change color/size etc) vertex in editable Polygon? var polygon = new google.maps.Polygon({ map:_map, path:path, editable:true, ...

Is it possible to mark (change color/size etc) vertex in editable Polygon? var polygon = new google.maps.Polygon({ map:_map, path:path, editable:true, ...

  1. google maps polygon area
  2. google maps polygon tool
  3. google maps polygon label
  4. google maps polygon api
  5. google maps polygon edit event
  6. google maps polygon creator
  7. google maps polygon coordinates tool
  8. google maps polygon remove point
  9. google maps polygon z index
  10. google maps polygon fill pattern
  11. google maps polygon title
  12. google maps polygon click event
  13. google maps polygon center
  14. google maps polygon to geojson
  15. google maps polygon overlay
  16. google maps polygon infowindow
  17. google maps polygon drawing
  18. google maps polygon get coordinates
  19. google maps polygon get bounds
  20. google maps polygon with hole

I have this ejs file which is to be send as a response using res.render() in node.js <!DOCTYPE html> <html> <head> <title>pilcit</title> </head> <body> &...

I have this ejs file which is to be send as a response using res.render() in node.js <!DOCTYPE html> <html> <head> <title>pilcit</title> </head> <body> &...

just been reading this: https://reactjs.org/docs/react-api.html#reactpurecomponent and trying to work out when would a function not return something pure? surely if you give a component the same ...

just been reading this: https://reactjs.org/docs/react-api.html#reactpurecomponent and trying to work out when would a function not return something pure? surely if you give a component the same ...

  1. when would you use react