当前位置:首页 > 知识库 > 正文

html打开新窗口输出文档页面(html简单网页代码)

上午接到博客访客的反馈,表示博客中的链接在原窗口打开的话,网站的体验非常的不好,而自己又懒的一个个去修改博客网页中的链接打开方式,就加了一个强制页面所有链接新窗口打开的代码,一招解决问题。

html打开新窗口输出文档页面(html简单网页代码)  第1张

html页面强制所有链接新窗口打开的代码

<base target="_blank">

将此代码放到,网页中的 <head>标签之内即可实现,当前页面所有A链接新窗口打开

html <base> 标签

<base>:标签当前页面上的所有的相对链接规定默认 URL 或 默认目标。

语法:

<base href="网址" target="打开的方式">

属性;

herf:规定的默认链接

target:链接打开的方式,参数有 _blank,_self 等,与A标签的 target 属性相同

例:html页面所有链接强制新窗口打开

<base target="_blank">

例:html页面所有链接强制在当前窗口打开

<base target="_self">

例:设置默认的URL

<!DOCTYPE html><html lang="en"><head> <base href="https://www.feiniaomy.com" target="_blank"> <title>Document</title></head><body> <a href="/post/1.html">我是相对链接,我可以打开 https://www.feiniaomy.com/post/1.html</a> <a href="http://www.baidu.com">我是绝对链接,我可以打开 http://www.baidu.com</a></body></html>

<base> 标签使用注意事项

1、一个页面中,<base> 标签只能出现一次

2、<base> 标签只能在 <head></head>标签中出现

3、<base> 属于单标签,没有结束标签,类似 <img> 标签

[db:内容2][db:内容3]

发表评论

最新文章

推荐文章