Setting the default TAB in a specific Menu Tab within the Menu Bar

I'm encountering some issues with this code. Specifically, the menu bar JavaScript is automatically clicking on the Second TAB instead of the First TAB when run.

JS CODE.

   var dolphintabs = {
    subcontainers: [],
    last_accessed_tab: null,

    revealsubmenu: function(curtabref) {
        this.hideallsubs();
        if (this.last_accessed_tab != null)
            this.last_accessed_tab.className = "";
        if (curtabref.getAttribute("rel")) 
            document.getElementById(curtabref.getAttribute("rel")).style.display = "block";
        curtabref.className = "current";
        this.last_accessed_tab = curtabref;
    },

    hideallsubs: function() {
        for (var i = 0; i < this.subcontainers.length; i++)
            document.getElementById(this.subcontainers[i]).style.display = "none";
    },

    init: function(menuId, selectedIndex) {
        var tabItems = document.getElementById(menuId).getElementsByTagName("a");
        for (var i = 0; i < tabItems.length; i++) {
            if (tabItems[i].getAttribute("rel"))
                this.subcontainers[this.subcontainers.length] = tabItems[i].getAttribute("rel");
            if (i == selectedIndex) {
                tabItems[i].className = "current";
                this.revealsubmenu(tabItems[i]);
            }
            tabItems[i].onclick = function () {
                dolphintabs.revealsubmenu(this);
            }
        }
    }
}

HTML Code :

<head>
<title>Custom Dolphin Tabs Menu</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="dolphin.js">
</script>
</head>

<body>

<div id="dolphincontainer">
...

CSS Code :

#dolphincontainer { ... }
...

For a sample, please visit the following link:

Answer №1

Make sure to include the rel attribute in your <a> tag for proper linking. Take a look at your navigation structure.

Hopefully, this information is beneficial!

UPDATED
Revise the following code snippet in your HTML file

tabs.initialize("tabnav", 0)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript will continue to run uninterrupted even after refreshing the webpage

Has anyone else encountered the issue of a javascript on a page continuing to run even after the page is refreshed? From what I understand, javascript is single-threaded and should stop running when the page is refreshed. Just to provide some background, ...

Sending a request to a PHP file using Ajax in order to display information fetched from

I am attempting to display the database row that corresponds with the student's forename and surname selected from the dropdown list. I have managed to store the first name and surname in a variable called clickeditem. However, I suspect there may be ...

Guide on redirecting to an HTML page on a local computer

Recently, I created an HTML page named A.html on my local computer which consists of 2 text fields and a button. I made a host entry to access the file via localhost. Upon clicking the button on A.html, it redirects me to a corporate login page where I ne ...

Is there a glitch in my redux-saga?

After developing a React Native app, I encountered an issue with my index.ios.js file where I was adding middlewares to the store. import React, { Component } from 'react' import { AppRegistry, } from 'react-native' import { Provider ...

Tips for displaying user-entered information from a form after submitting it with PHP

How can I display the email in the email text input field with this code? It doesn't seem to work correctly when there is a failed login attempt. value= "if(isset($_POST['submit'])){ ?PHP echo $_POST[''email']?>"; ...

Adjust the minimum height and width when resizing the window

Apologies in advance if this has already been addressed, but I have tried solutions from other sources without success. My Objective: I aim to set the minimum height and width of a div based on the current dimensions of the document. This should trigger ...

Transforming an array in JavaScript into a JSON object

I'm currently working on creating a loop in JavaScript or jQuery to generate a new JSON object from an array. The goal is to convert an input JavaScript array into a desired format for the output. Here's the input array: INPUT: [ { ...

Is there a way to successfully submit multiple locations, each separated by commas, through the multipart form?

Here is my HTML form: <form method="POST" enctype="multipart/form-data" v-on:submit.prevent="handelSubmit($event);"> <div class="clear"> <div class="col-md-3"></div> <div class="col-md-6"> <div class="form ...

Utilizing the power of Vue.js and D3.js in tandem to create dynamic force simulations

Currently, I am attempting to retrieve data from a Restful API call and utilize it to create a d3.js force simulation. However, I have encountered an issue where if I use the data from the API call directly, the simulation treats it as if there is no data ...

Is the order of execution of extraReducers before or after the reducers?

I was curious about the createSlice function in redux-toolkit and how it handles the order of execution for extraReducers compared to reducers. Can we determine if the extraReducers are executed before or after the reducers, or is the order indeterminate? ...

Issues with spacing in navigation bar

I've been searching and experimenting for hours, but I can't seem to make it work. In my "inline-form," I have a button on the left, an input field in the middle, and a button on the right within a navbar. Everything displays correctly when the ...

Tips for utilizing jQuery to substitute strings within a content variable?

$content = "Please locate the student results where Date of birth **IS BETWEEN** 2012-02-18 00:00:00 AND 2013-02-18 00:00:00 AND name **IS NOT EQUAL TO** 'John' AND marks **IS BETWEEN** 40 AND 75 AND grade **EQUAL TO** 'A' AND AGE **I ...

Tips for designing a dropdown menu for selecting the number of passengers

Looking for guidance on adding a passenger count dropdown form similar to the one in the image below. I've searched everywhere but can't find a demo or any help. Can someone assist me with this? https://i.sstatic.net/RO1vi.jpg Appreciate any he ...

Instructions on adjusting the height of a flexbox container to utilize the available space

I am facing a challenge in grasping the interaction between flexbox containers and other elements on a webpage. When I have only a flexbox on my page, everything works smoothly. However, when I introduce other elements, things start acting strangely. It se ...

What are the benefits of using React.useMemo or React.useCallback within component props?

Exploring efficient ways to implement TailwindCSS in React, considering its utility-first nature leading to component-heavy code (e.g. className="w-full bg-red-500"). One approach is creating a utility function like: utils/tailwind.ts const tw = (...clas ...

The function webpack.validateSchema does not exist

Out of the blue, Webpack has thrown this error: Error: webpack.validateSchema is not defined Everything was running smoothly on Friday, but today it's not working. No new changes have been made to the master branch since Friday. Tried pruning NPM ...

Strange behavior in Angular controllers

There's a timeframe control in my app that allows users to adjust a value displayed in months. You can use the right arrow to increase the value (e.g., January -> February), the left arrow to decrease it, or manually input a different month. Howev ...

What could be causing my jQuery script to not load properly on the first attempt?

I have a jQuery script set up on this particular webpage just before the ending body tag. Here is the script: <script> $(document).ready(function(){ var demomain = $(".demo-bg section"); var demomainW = demomain.height()+ 150 ...

Utilizing data in mongoose: A beginner's guide

I have two database models: User and Conversations. The User model has the following schema: const userSchema = mongoose.Schema({ username: String, logo: String, ..... }) and the Conversation schema is as follows: const conversationSchema = mongo ...

When attempting to log an AJAX/JSON request, the console.log statement is displaying 'undefined'

Being new to AJAX, I have encountered an issue that I believe others may have faced as well. Despite numerous attempts and extensive research, I am unable to find a solution to this error. I am confident that it is something simple. Any help would be gre ...