超链接打开目标(target)的测试
互联网 发布时间:2008-10-17 18:56:31 作者:佚名
我要评论
链接的target属性决定了链接在哪边打开,它的值通常为以下五种:_blank、_self、_parent、_top和自定义,依次表示为:新窗口、当前窗口、父窗口、顶层窗口和框架。当所指名称的框架不存在时,自定义作用等同于_blank。今天我们主要测试一下当所指名称的框架处于不同层次页面
链接的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="https://www.jb51.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="https://www.jb51.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="https://www.jb51.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="https://www.jb51.net/" target="frame1">Links</a>
bbb.htm:
<iframe name="frame1" src="" width="200" height="200"></iframe>
测试结果:
当target="frame1"时,在bbb.frame1中打开;
二、结论
当要打开一个链接时,先在本页面中搜索指定名称(target)的框架,找不到则在下层页面中搜索,还找不到就到上层页面中搜索,都找不到打开一个新的窗口!
一、测试
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="https://www.jb51.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="https://www.jb51.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="https://www.jb51.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="https://www.jb51.net/" target="frame1">Links</a>
bbb.htm:
<iframe name="frame1" src="" width="200" height="200"></iframe>
测试结果:
当target="frame1"时,在bbb.frame1中打开;
二、结论
当要打开一个链接时,先在本页面中搜索指定名称(target)的框架,找不到则在下层页面中搜索,还找不到就到上层页面中搜索,都找不到打开一个新的窗口!
相关文章
文章介绍了HTML中img标签的使用,包括src属性(指定图片路径)、相对/绝对路径区别、alt替代文本、title提示、宽高控制及边框设置等,本文主要给大家介绍HTML img标签和超链2025-06-20- HTML meta标签用于提供文档元数据,涵盖字符编码、SEO优化、社交媒体集成、移动设备适配、浏览器控制及安全隐私设置,优化页面显示与搜索引擎索引,本文给大家介绍HTML中meta2025-06-20
input 标签主要用于接收用户的输入,随 type 属性值的不同,变换其具体功能,本文通过实例图文并茂的形式给大家介绍HTML input 标签,感兴趣的朋友一起看看吧2025-06-20
这篇文章主要介绍了html 滚动条滚动过快会留下边框线的解决方案,解决方法很简单,可以将 dialog 单独拿出来别放在 transform 的子元素里,需要的朋友可以参考下2025-06-09- 本文将介绍如何使用<img>标签在 HTML 中添加图片,并展示一些常见的用法和技巧,通过本文的介绍,应该掌握了在 HTML 中添加和调整图片的基础知识,感兴趣的朋友一起看2025-05-16
- HTML表格用于在网页上展示数据,通过标签及其相关标签来创建,表格由行和列组成,每一行包含一个或多个单元格,单元格可以包含文本、图像、链接等元素,本文将详细介绍HTML表格2025-03-12
- 本文介绍了三种禁止HTML页面滚动的方法:通过CSS的overflow属性、使用JavaScript的滚动事件监听器以及使用CSS的position:fixed属性,每种方法都有其适用场景和优缺点,感兴2025-02-24
在 Web 开发中,文本的视觉效果是提升用户体验的重要因素之一,通过 CSS 技巧,我们可以创造出许多独特的效果,例如文字镂空效果,本文将带你一步一步实现一个简单的文字镂空2024-11-17
在Html中,a标签默认的超链接样式是蓝色字体配下划线,这可能不满足所有设计需求,如需去除这些默认样式,可以通过CSS来实现,本文给大家介绍Html去除a标签的默认样式的操作代码2024-09-25- 在HTML中,可以通过设置CSS的resize属性为none,来禁止用户手动拖动文本域(textarea)的大小,这种方法简单有效,适用于大多数现代浏览器,但需要在老旧浏览器中进行测试以确保2024-09-25






最新评论