During this time, I was building a website, and the space did not support ASP, so I picked up the JavaScript tutorial and looked at it to see if I could achieve dynamics in a static space. Of course, this dynamic is not real, so to speak. It's just a "pseudo-dynamic" :)
The most basic function of a dynamic page is in the form of news.asp?id=1, so I started working on this goal, and after working on it for a while, it actually achieved some results. ~The basic idea is: get the address of the current file from the browser's address bar, then extract the id from it, and finally use an inline frame to display related content. The following is the basic code
<script> <br>var str, len,pos,id,fn; // Define some variables <br>str=top.window.location.href; // Get the natural file address <br>len=str.length; // Get the address length <br>pos =str.indexOf("?id=",0); // Get the starting address of "?id="<br>if(pos>0) // Determine whether "?id=" <br>{ <br> id=str.substring(pos 4,len); // Get ID <br> fn="<iframe src='news/" id ".htm'></iframe>" // Included Display relevant content in the embedded frame <br> document.write(fn); // Output <br>} <br>else <br>{ <br> document.writeln("Wrong parameter!"); // Does not exist ID <br>} <br></script>
In this way, you can make news pages and put them in the news directory, and then call news.htm?id=1 externally to view related News~~ Of course, the code here is not mature, for example, it does not determine whether the ID is a number, etc. This will be gradually improved in the future:)