用好href的target, base href

简介:

<base href>就是指网页里面的相对链接 的前缀url,如在<head></head>部分定义了此链接为http://ent.sina.com.cn/ ,那么下面的<a href=aaa.html></a>代表http://ent.sina.com.cn/aaa.html 
这个标签的用处是解决编程时候的相对路径问题 ,你可以把它生成相对路径,如<a href="sdsd/dsd.html">sddsds</a>,只要在head部分加上<base href=http://localhost/abc/>即可。

注意<a href="/ sdsd/dsd.html">sddsds</a>不会加上相对链接 的前缀url

自己写绝对路径也不会加上相对链接 的前缀url<a href=" http://www.baidu.com ">baidu </a>
所以说,这个标签主要为了解决web编程的时候一些相对路径的问题 。
当然,这个base还有一个用法,如在head部分加上这么一行: <base href="_blank"> ,就是默认所有链接在新窗口打开。

 

相关文章
|
5月前
src和href的区别是什么?
src和href的区别是什么?
44 0
|
5月前
location.href
location.href
|
5月前
|
前端开发
src与href的区别?
src与href的区别?
|
前端开发
location.href与window.open()的用法与区别,你都知道吗?
通常在Web开发中,打开一个页面有两种方式,一种是使用location的href属性来打开一个页面;还有一种就是使用window对象下的open()方法。
584 0
location.href与window.open()的用法与区别,你都知道吗?
|
JavaScript Java
window.location.href跳转问题2
"window.location.href"、"location.href"是本页面跳转 "parent.location.href"是上一层页面跳转 "top.location.href"是最外层的页面跳转 举例说明: 如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写 "window.
973 0

热门文章

最新文章