This time because to do a website, and the space does not support ASP, so took up the JavaScript tutorial looked, see can be in the static space to achieve dynamic, of course, this dynamic is not the real sense of the, can be said to be just a "pseudo dynamic":
The most basic features of dynamic pages, is news.asp?id=1 such form, so I take this target to start, get a while really some effect ~ The basic idea is: get the address of the current file from the address bar of the browser, then extract the ID from it, and finally use the inline frame to display the relevant content. Here's the basic code
Copy Code code as follows:
<script>
var str,len,pos,id,fn; Define some variables
Str=top.window.location.href; Get the address of the course file
Len=str.length; Get address length
Pos=str.indexof ("? id=", 0); Get start address for "? id="
if (pos>0)//To determine if there is a "? id="
{
Id=str.substring (Pos+4,len); Get ID
fn= "<iframe src= ' news/" + ID + ". htm ' ></iframe>"//inline frame display related content
document.write (FN); Output
}
Else
{
Document.writeln ("wrong argument!") "); ID not present
}
</script>
In this way, you can put the news into a page in the information directory, and then call News.htm?id=1 on the outside can come to see the relevant news ~ ~ Of course, the code here is not mature, such as no judgment ID is the number, etc., such as later to gradually improve: