Hyperlink的target属性原来可以这么用
2005-01-20 22:48
447 查看
也许是我大惊小怪,我现在才发现 hyperlink的target属性可以这么用
大家可以看一下asp.net 的 ASP.NET Articles -- Updated Daily! ,点击链接在新窗口中打开某一篇文章,不要关闭打开的新窗口,点击另外一篇文章的链接,可以发现新的链接不会打开新的窗口,而是在先前打开的窗口中加载,这样我们就可以防止打开过多的新的窗口。
好奇,看了一下源代码,没有什么特别,可是我查了一下msdn, 发现target属性解释如下:
Possible Values
The property is read/write. The property has a default value of _self.
看看我上面标注为红色部分就知道是为什么了。asp.net的文章列表中的hyperlink设置了这样的属性 target="_new"。
试试下面的代码,我也作出了同样的效果
AspnetUpload.net
Upload4Asp.net
不过有一点不好,就是我打开新页面之后,再次返回主页面点击其它链接,虽然新的链接已经加载,但是并不自动获得焦点而是停留在主页面。想了个办法解决,就是在打开的新页面中加一点javascript代码:
大家可以看一下asp.net 的 ASP.NET Articles -- Updated Daily! ,点击链接在新窗口中打开某一篇文章,不要关闭打开的新窗口,点击另外一篇文章的链接,可以发现新的链接不会打开新的窗口,而是在先前打开的窗口中加载,这样我们就可以防止打开过多的新的窗口。
好奇,看了一下源代码,没有什么特别,可是我查了一下msdn, 发现target属性解释如下:
Possible Values
sTarget | String that specifies or receives one of the following values.
|
看看我上面标注为红色部分就知道是为什么了。asp.net的文章列表中的hyperlink设置了这样的属性 target="_new"。
试试下面的代码,我也作出了同样的效果
AspnetUpload.net
Upload4Asp.net
不过有一点不好,就是我打开新页面之后,再次返回主页面点击其它链接,虽然新的链接已经加载,但是并不自动获得焦点而是停留在主页面。想了个办法解决,就是在打开的新页面中加一点javascript代码:
相关文章推荐
- Hyperlink的target属性原来可以这么用 --zt
- 实体类的枚举属性--原来支持枚举类型这么简单,没有EF5.0也可以
- 实体类的枚举属性--原来支持枚举类型这么简单,没有EF5.0也可以
- 实体类的枚举属性--原来支持枚举类型这么简单,没有EF5.0也可以
- 原来命令行参数处理可以这么写-getopt?
- JavaScript 原来可以这么优雅
- java连连看源码分享(原来连连看这么简单,你也可以写)
- 原来自定义模型绑定器还可以这么玩
- Oracle merge into原来可以这么写
- 原来幸福可以这么简单
- 原来编译原理可以这么学
- 原来编译原理可以这么学 .
- 车原来可以这么开
- svg拉伸,原来凹凸可以这么玩
- 第一交易所即将面世,交易所原来可以这么玩!
- 涨姿势了,原来Android屏幕适配还可以这么玩
- 心电图测量原来可以这么简单
- 原来,数学也可以这么美的-采用matlab画爱心(附带 MatLab 代码)
- 面试题之:HTML <a> 标签的 target 属性中有哪些可以在新窗口中打开链接?
- 原来编译原理可以这么学