Dynamic | expansion | The ie4.x made by the Microsoft Company makes the Web page in accordance with the HTML4 standard become fashionable, and this kind of webpage has greatly improved in the dynamic function. In particular, the page can be embedded in the script statement, so that any piece of text in the page can be displayed when needed, when not needed to hide, using this feature, you can design a scalable hierarchical list on the page. This list actually shows a hierarchical tree structure in which the reader can click on an item on the previous level and expand or close its next layer. After understanding the implementation mechanism of the DOM in the HTML4 standard and the definition of the style form, it is easy to find a way to implement this list. But generally speaking, this list of items are more, if every time with hand-made, not only very cumbersome, but also very easy to make mistakes, so to really apply to the actual page production, there must be a more automatic method. I through the experiment, using ASP way to complete a more general implementation process, a little change can be applied to a variety of home page production process, very convenient, here I write it to the dedication to everyone, I hope we can give more comments.
Simple to implement
To scale on a Web page, you first need to know how to hide and display a piece of text in a page as needed. Let's look at the following snippet of HTML format:
<div id= "test" style= "Display:none" > Text to hide </Div>
This is an HTML statement that conforms to the HTML4 standard, and the text sandwiched between <Div> will not appear on the page because its display property for the style form is none. (as this article does not mainly introduce HTML4 style form, the reader is asked to find relevant information.) As long as you can dynamically set the display property to NULL, the default value, the text can be dynamically displayed. This requires script support, and the following is a two JavaScript function that shows and hides the text above, as long as the ID value of the custom Div is put in, and the corresponding text is displayed or hidden:
<script language= "JavaScript" >
function Showdiv (divid)
{
Document.all[divid].style.display= ';
return 0;
}
</script>
function Hidediv (divid)
{
Document.all[divid].style.display= ' None ';
return 0;
}
</script>
With these two functions, you need to consider when to call them. Readers familiar with script programming, of course, have come to the idea that they can be placed in the event response process. The general form may be this:
<a href= "#" Return Hidediv (' Test '); > Hide
Combining the above fragment into an HTML file is a complete example, using IE4 to test to see if the desired effect is achieved. (Note: JavaScript is case sensitive, typographical errors may occur, in practical applications, preferably in lowercase.) )
With the above understanding, the production of a scalable hierarchical list, just from simple to complex process, so I do not have to do any explanation, only provide an example for reference, this example is our next step to use the program to achieve a result:
FileName: lstest.htm
<title>dylist test</title>
<script language= "JavaScript" >
/*
Changes the display state of an object based on the current properties of the object
*/
function Onclickdiv (divid)
{
if (document.all[divid].style.display== ' none ')
{document.all[divid].style.display= ';}
Else
{document.all[divid].style.display= ' none ';}
return 0;
}
</script>
<body>
<div id= "Dy1" style=display:>
<a href= "#") > Domestic Press
<div id= "Dy2" style=display:none>
Daily
Guangming
<a href= "#") > Volkswagen daily
<div id= "Dy3" style=display:none>
Volkswagen daily
Rural Mass
Qilu Evening News
Daily life
</div>
</div>
<a href= "#") > Search engine
<div id= "Dy4" style=display:none>
Yahoo
Sohu
</div>
</div>
</body>
Automate
The top of the pile of things, who read will be dazzled. However, the effect of browsing on the IE4, and really cool to make people itch, so the cost of a little effort, with the program to automate this cumbersome production process, is entirely worthwhile. A simple idea: the tree-like hierarchy of data saved to a concise file carrier, write a general program from the carrier file to read data, generate the HTML file we want. So the first step is to choose what kind of carrier, the database method is certainly the most worthy of consideration, but this will involve a lot of problems, I think in another topic to discuss it, Here I chose the Windows platform commonly used on the. ini file, this file is suitable for the preservation of tree-like hierarchical data, and the system platform has provided the basic operational functions, can save a lot of effort.
I have made this process into the form of ASP (Active Server Page), so that can be used directly, of course, sometimes the need for static HTML files, then you can transfer the code in ASP to VB program, it is not difficult. In order to be processed in ASP. ini file, I used to write an ActiveX service object, this service object will be operating on the. ini file of various function functions encapsulated in a class (class), I used to have a smooth (about this service object of the specific instructions, please see my " The application of the configuration file (. ini) in the VB5 in the article, listen to other people say in the publication of what I have seen this paper, but I have not received any notice, so it also attached to the back.
Let's start with our program design, and take a look at the form of tree-like hierarchical data saved in an. ini file:
FileName: Lstest.ini
[Root]
A= Domestic Press
B= Search Engine
A
A1= People's Daily, http://www.peopledaily.com.cn
A2= Guangming, http://www.gmdaily.com.cn
a3= Public Daily
[A3]&n