When designing web pages, many web pages require the same border pattern and navigation bar. FrontPage provides us with shared borders to facilitate design. However, this is not very convenient. After all, the same content is added to each web page, which virtually increases the number of web pages. Of course, for dynamic web pages, this is not a problem, but what if it is static?
When designing web pages, many web pages require the same border pattern and navigation bar. FrontPage provides us with shared borders to facilitate design, but, This is also inconvenient. After all, the same content is added to each web page, and the web page increases invisibly. Of course, this is not a problem for dynamic web pages, but what if it is static?
How can this shortcoming be overcome through the framework? This can be achieved, but the frame has caused another trouble, that is, if you directly open the internal page of the frame and take off the gorgeous coat, will it look very monotonous? Here we find a good way to take off the coat. The webpage automatically puts on the jacket, have you thought about it? If you are not interested in this topic, you can go away, we will discuss it in detail below.
In frame web pages, the src parameter is usually used to specify the web page address within the frame. What we have to do is, when opening this address directly, let it automatically detect and then put on the coat. Of course, we must first add the detection code to the web page. As follows:
The following is a quoted fragment:
<script>
if(top.location==self.location)
{
top.location="index.htm?"+self.location;
}
</script>
It's that simple. Note that index.htm is the coat web page address. The next thing to do is how to make the coat web page automatically add this part of the content. We need to parse the web page address in the coat web page, find the parameters, and then point the frame src parameter to This parameter will do the trick, the code is as follows:
The following is a quote snippet:
<script>
document.write('<iframe id="mid" name="mid" width="100%" height="100%" frameborder="0" scrolling="auto"')
var n=self.location.href.indexOf("?")//Check whether it contains parameters
if(n>0)//parameters exist
{
//Point to parameters
document.write(" src="+self.location.href.substr(n+1))
}
document.write('></iframe>')
</script>
The iframe framework is used here. The specific application can be seen on my website ggg82.126.com.
You can click here to see the effect. If there is anything you don’t understand, you can also contact me. If you have any good opinions, please feel free to discuss them with me.