A tab web page is a perfect candidate for the technology of Active Client Pages (ACP). It's a web page with buttons at the top. When you click a button, all the HTML content below the line of buttons changes. It is as if each button has a page hidden in it. ACP makes loading those pages go much more quickly.
The first three lines are XHTML requirements. You have a HEAD element, which has a JavaScript. The function of this JavaScript in the HEAD element is to display the page content of the tab button clicked. I will explain the details shortly.
The web page has the BODY element. This BODY element has the DIV element and another JavaScript. The content of the DIV element you see after the file has just been called is that of the first real page.
The JavaScript has the Ajax functions. However, the first statement in the script copies the content of the DIV element to the variable that holds the string of the first page. We shall learn more about this variable later.
The loading of the first file should be done in such a way that when the user clicks the tab for the first real page, after clicking the tab for the second or third real page, the content of the first real page should be available. You can say that this statement stores the content of the first real page.
The JavaScript in the Head Element
The JavaScript in the HEAD element begins with the following three lines:
tab1Page = "";
tab2Page = "";
tab3Page = "";
Each of these variables will hold the string content of a page. The first one holds the content for the first tab, the second one holds it for the second tab and the third holds it for the third tab. The string values for the content are assigned in the code. Next in this script, you have the following function:
When any tab is clicked, this is the function that is called. The function receives the button number of the tab clicked as an argument. In this example I used string instead of integer for the button number.
The function has a switch statement. If the button number is "1," the first case replaces the content of the DIV element with value of the tab1Page variable. The ID of the DIV element is "D1." If the button number is "2," the first case replaces the content of the DIV element with the value of the tab2Page variable. If the button number is "3," the first case replaces the content of the DIV element with the value of the tab3Page variable. This is how the page content is changed.