

Web Dev Best Practices: Implicit target=''_blank'...
source link: https://www.tuicool.com/articles/U7J7BbY
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

The target="_blank"
href attributes has been been the subject of many discussions. When is it right to use it? Should we use it at all? Is it actually deprecated? Is it good user experience? Does it break user expectations? Etc.
And I have a strange proposal for improving the standard behavior in browsers — implicit target=_blank"
in certain contexts. But let's try to list when target="_blank"
is a good idea:
- On pages with forms when the user may need additional information in order to fill the form but you don't want them to leave the form and lose their input.
- On homepage-like websites, e.g. Twitter and Facebook, where your behavior is "browsing" and opening a link here and there. It may be applied to things like Reddit or Hacker News, though it's currently not implemented that way there.
- In comment/review sections where links are user-provided — this is similar to the previous one, as the default behavior is browsing through multiple comments and possibly following some of them.
The typical argument here is that if a user wants to open a new page, they can do that with either the context manu or ctrl+click. Not many users know that feature, and even fewer are using it. And so many of these pages are confusing, and combined with a sometimes broken back-button it becomes a nightmare.
In some of these cases, JavaScript is used to make things better (and more complicated). In the case of forms, JavaScript is added to warn people against leaving the page with an unfinished form. JavaScript is used to turn certain links to target="_blank"
ones. Some people try to open new tabs with JavaScript.
So my proposal is to introduce a with the following values for open-links and on-form:
open-links="new-tab" open-links="new-window" open-links="new-tab-on-form" open-links="new-window-on-form" open-links="warn-on-form"
The default value, I think, should be new-tab-on-form
. Security has to be considered, as malicious pages may affect the page that used target="_blank"
.
It might introduce new complexities and may confuse users further. But I think it's worth trying to fix this important part of the web rather than leaving each website handle it on their own (or forgetting to handle it).
Recommend
-
127
在网页中使用链接时,如果想要让浏览器自动在新的标签页打开指定的地址,通常的做法就是在 a 标签上添加 target等于"_blank" 属性。 然而,就是这个属性,为钓鱼攻击者带来了可乘之机。 起源 parent 与 opener 在说 opener 之前,
-
52
When want to open a new page in a new tab on clicking a link on a page, the usual way of achieving this is to use target="_blank" property in a tag. However, t...
-
8
Window.open() and target=”_blank” have a security vulnerability We often use the HTML target="_blank" or the Javascript window.open() to open pages in new tabs. // in html <a href="www.google.com" target=...
-
5
Jul 27th, 2020Hasty Treat - Target=_blank security issue? What's the deal with noopener and noreferrer?👇 Download Show
-
7
window.open()和target= blank存在安全漏洞发布于 10 月 21 日作者:Daniel译者:前端小智来源:js-craft
-
9
intro I came across an interesting vulnerability the other day. It has been talked about before, but was new to me and I found an exploitable example in the wild so I thought I would write a post about it. The vulnerability in quest...
-
8
Best Practices for Writing on DEV (2 Part Series) Hey hey DEV Community, Sloan...
-
9
Hey again, Sloan here! 🦥 We’re sharing some tips for success when it comes to writing on DEV. If you’ve been looking to improve your technical writing skills, make the most of DEV as a blogging platform, and take your content to the next...
-
5
Hey again, Sloan here! 🦥 We’re sharing some tips for success when it comes to writing on DEV. If you’ve been looking to improve your technical writing skills, make the most of DEV as a blogging platform, and take your content to the next l...
-
6
Hey devs! Time for another installment in our Best Practices for Writing on DEV series. Today I'll share some guidelines for choosing and framing your topic. Topics We created DEV because we wanted to buil...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK