超链接打开目标(target)的测试


链接的target属性决定了链接在哪边打开,它的值通常为以下五种:_blank、_self、_parent、_top和自定义,依次表示为:新窗口、当前窗口、父窗口、顶层窗口和框架。当所指名称的框架不存在时,自定义作用等同于_blank。今天我们主要测试一下当所指名称的框架处于不同层次页面中或不同层次页面中都有该名称框架时链接在哪个框架中打开?

一、测试

1.测试一:指定名称的框架处于不同层次页面中

index.htm:
<iframe name="frame1" src="" width="400" height="400"></iframe>
<iframe src="aaa.htm" width="400" height="400"></iframe>

aaa.htm:
<iframe name="frame2" src="bbb.htm" width="300" height="300"></iframe>
<a href="http://www.phpstudy.net/" target="frame1">Links</a>

bbb.htm:
<iframe name="frame3" src="" width="200" height="200"></iframe>


测试结果:
当target="frame1"时,在index.frame1中打开;(为方便说明,框架位置统一用"页面名称.框架名称"格式)
当target="frame2"时,在aaa.frame2中打开;
当target="frame3"时,在bbb.frame3中打开;

2.测试二:不同层次页面中存在同名称的框架

index.htm:
<iframe name="frame1" src="" width="400" height="400"></iframe>
<iframe src="aaa.htm" width="400" height="400"></iframe>

aaa.htm:
<iframe name="frame2" src="bbb.htm" width="300" height="300"></iframe>
<a href="http://www.phpstudy.net/" target="frame2">Links</a>

bbb.htm:
<iframe name="frame2" src="" width="200" height="200"></iframe>


测试结果:
当target="frame2"时,在aaa.frame2中打开;

3.测试三:不同层次页面中存在同名称的框架

index.htm:
<iframe name="frame2" src="" width="400" height="400"></iframe>
<iframe src="aaa.htm" width="400" height="400"></iframe>

aaa.htm:
<iframe name="frame2" src="bbb.htm" width="300" height="300"></iframe>
<a href="http://www.phpstudy.net/" target="frame2">Links</a>

bbb.htm:
<iframe name="frame3" src="" width="200" height="200"></iframe>


测试结果:
当target="frame2"时,在aaa.frame2中打开;

4.测试四:不同层次页面中存在同名称的框架

index.htm:
<iframe name="frame1" src="" width="400" height="400"></iframe>
<iframe src="aaa.htm" width="400" height="400"></iframe>

aaa.htm:
<iframe name="frame2" src="bbb.htm" width="300" height="300"></iframe>
<a href="http://www.phpstudy.net/" target="frame1">Links</a>

bbb.htm:
<iframe name="frame1" src="" width="200" height="200"></iframe>


测试结果:
当target="frame1"时,在bbb.frame1中打开;

二、结论

当要打开一个链接时,先在本页面中搜索指定名称(target)的框架,找不到则在下层页面中搜索,还找不到就到上层页面中搜索,都找不到打开一个新的窗口!

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3