When to use target=“_self”

谁说胖子不能爱 提交于 2019-11-29 16:19:07

问题


When does the _self frame target becomes useful or worth using it?

Isn't it (always?) the default behavior?


回答1:


The default can be changed by using the <base> tag in the <head>:

<base href="http://www.mysite.com/" target="_blank"/>

In this case, you can use target="_self" on a link to override the target set by base.




回答2:


_self target value could also be useful in conjunction with AngularJS's HTML5 location mode when you do need to force full page reload for links with the same base as your single page app.

https://docs.angularjs.org/guide/$location#html-link-rewriting

In cases like the following, links are not rewritten; instead, the browser will perform a full page reload to the original link.

Links that contain target element Example: <a href="/ext/link?a=b" target="_self">link</a>

...




回答3:


<base target="_self"/>

Was very handy for me when I had a page I wanted to load into Firefox's sidebar. I wanted any links clicked to stay in the sidebar instead of opening the links in the main window. Adding the above to the <head> fixed me right up and all the page's links stay within the sidebar.



来源:https://stackoverflow.com/questions/15771047/when-to-use-target-self

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!