zoukankan      html  css  js  c++  java
  • HTML中的target(_self,_blank)用法总结

    最近一个项目,多次遇到target='_self', target='_blank'的用法, 再次总结一下:

    1.<a>标签

    <a href="xxxx"  target="_self">XX</a>

    <a href="xxxx"  target="_blank">XX</a>

    2.<form>标签

     <form name=alipayment action=alipayapi.jsp method=post target="_blank">  (该代码来自支付宝的demo)

    3.window.open

    var url =xxxx;
    window.open(url,'_self');

    (window.location.href=xxx;)

    在同一个项目中遇到了target的三种用法。

    target的所有取值以及它们的含义:

    _blank:在新窗口中打开;

    _self:默认。在相同的框架中打开;

    _parent:在父框架集中打开;

    _top:在整个窗口中打开;

    其实我们一般很少用到frameset标签,所以一般我们只是经常用到target='_self' 和 target='_blank',分别用于在当前页面打开,和在一个新的页面打开。

    在 HTML 4.01 中,不赞成使用 form 元素的 target 属性;在 XHTML 1.0 Strict DTD 中,不支持该属性。

    window.open与window.location.href的区别:

    window.open() 用来打开新窗口,但是加上'_self',可以达到使用window.location.href的效果
    window.location.href 用来替换当前页,也就是重新定位当前页

    window.open() 是可以在一个网站上打开另外的一个网站的地址
    而window.location.href 是只能在一个网站中打开本网站的网页

  • 相关阅读:
    八数码难题 (codevs 1225)题解
    小木棍 (codevs 3498)题解
    sliding windows (poj 2823) 题解
    集合删数 (vijos 1545) 题解
    合并果子 (codevs 1063) 题解
    等价表达式 (codevs 1107)题解
    生理周期 (poj 1006) 题解
    区间 (vijos 1439) 题解
    区间覆盖问题 题解
    种树 (codevs 1653) 题解
  • 原文地址:https://www.cnblogs.com/digdeep/p/4308294.html
Copyright © 2011-2022 走看看