Html Target Attribute not supported

前端 未结 7 1082
一个人的身影
一个人的身影 2021-02-19 05:23

I was just on w3Schools looking at target and found that it is no longer supported by any of the major browsers. A brief google search did not reveal the reason for this? Should

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 06:19

    target attribute is supported by all browsers.

    It has been removed from HTML4 Strict and XHTML 1 Strict, because these don't allow frames, and because forcing new windows on users isn't always good idea (e.g. Back button in new window will be disabled, which confuses some users).

    target has been added back in HTML5. You can use it, but don't abuse it.

    It's OK if you want to open help page in new window on page that has a long form (you don't want users to lose content of the form), but it's not OK to force every link in new window in hope it'll make your page harder to leave.

    And please don't try cheat validator by using scripts to open new windows. It gives same negative effect to users (or even worse if it breaks when JS is disabled), but is harder to detect and control than target.

    BTW: Please don't treat W3Schools as authoritative. They're not affiliated with W3C in any way, and their tutorials often contain mistakes.

提交回复
热议问题