target=_parent与target=_top的区别与用途

本文详细解释了HTML中链接目标(target)属性的四个值:_blank、_self、_parent 和 _top 的含义及应用场景。特别是对于嵌套iframe的情况,说明了如何使用_target属性来控制页面加载的行为。

转自:http://www.taoshaw.com/taoshaw/article.asp?id=1868

在手动改HTML代码时经常会用到target参数,常用的有两个target=_blank 和target=_self意思为:
1. target=_blank表示在新窗口中打开该链接;
2. target=_self表示相同框架,即在当前窗口(或当前选项卡)中打开该链接。
还有两个不常用的:
3. target=_parent,将链接的文件载入含有该链接框架的父框架集或父窗口中。如果含有该链接的框架不是嵌套的,则在浏览器全屏窗口中载入链接的文件,就象_self参数一样。 
4. target=_top,在当前的整个浏览器窗口中打开所链接的文档,因而会删除所有框架不写的话就是表示默认值,默认值一般跟浏览器有关。 

比如:

网A中镶嵌iframe了网页B,网页B又镶嵌iframe了网页C:
1. 如果网页C中连接设置target=_parent,则跳将网页B去掉直接A中嵌入网页C中链接页面;
2. 而如果网页C中target=_top ,则直接跳出所有iframe框架,直接转向C中链接页面。

以下代码,请帮我将Textview修改为一个imageview 。谢谢 。<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:didi="http://schemas.android.com/apk/res-auto" > <com.blog.demo10.NestedViewGroup android:id="@+id/dd_view_group" android:layout_width="match_parent" android:layout_height="match_parent" didi:header_id="@+id/view_bg" didi:target_id="@+id/target_layout" didi:inn_id="@+id/inner_rv" didi:header_init_top="0" didi:target_init_bottom="250"> <TextView android:id="@+id/view_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:textColor="#f00" android:textSize="25sp" android:textAllCaps="false" android:text="@string/txt_nested_scroll_bg" /> <LinearLayout android:id="@+id/target_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#fff"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/inner_rv" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> </com.blog.demo10.NestedViewGroup> <androidx.appcompat.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" didi:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> </RelativeLayout>
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值