在
框架网页中,通常使用
src参数指定框架内的网页地址,我们要做的就是,当直接打开这个地址时,让它自动监测然后再穿上外套,当然,首先要在网页内添加检测代码,如下:
以下是引用片段:
<script>
if(top.location==self.location)
{
top.location="index.htm?"+self.location;
}
</script>
注意,index.htm是外套网页地址,接下来要做的就是,怎样让外套网页自动添加这部分内容,我们要在外套网页中解析网页地址,找到参数,然后将框架src参数指向该参数就行了,代码如下:
以下是引用片段:
<script>
document.write('<iframe id="mid" name="mid" width="100%" height="100%" frameborder="0" scrolling="auto"')
var n=self.location.href.indexOf("?")//查看是否包含参数
if(n>0)//存在参数
{
//指向参数
document.write(" src="+self.location.href.substr(n+1))
}
document.write('></iframe>')
</script>
叶子树:www.webshu.net