无效的html(href目标标签) [英] invalid html (href target tag)

查看:104
本文介绍了无效的html(href目标标签)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇这应该如何正确完成。



我通过w3 html validateor运行了一个页面,我收到了一条错误消息

第47行,列54:Attributetarget存在,但不能用于此元素。**

 < ul><< ; li>< a href =./ jobops / 1000 Design PM.pdftarget =blank> 1000 Design PM< / a>< / li> 

您已在文档中使用上述属性,但您使用的文档类型不支持该元素的属性。此错误通常是由于严格文档类型与使用框架的文档(例如,您必须使用过渡文档类型以获取目标属性)不正确地使用或通过使用供应商专有的扩展名(例如 marginheight(这通常是通过使用CSS来达到预期的效果)。



关于如何打开一个新窗口但不能使用链接的任何想法target tag?

解决方案

您可以使用 JavaScript来打开新窗口,它避免了在现代HTML中无效目标的问题。



然而,这绕过了人们用来警告新窗口(或阻止它们打开)的各种系统,所以你最好使用target属性(并切换到允许它的Doctype)。

更好的是留给用户决定他们什么时候需要一个新的窗口。除了烦恼因素之外,他们还引入了辅助功能问题


I've curious how this should be properly done.

I ran a page im working on through the w3 html validateor and I got one error message

Line 47, Column 54: Attribute "target" exists, but can not be used for this element.**

<ul><li><a href="./jobops/1000 Design PM.pdf" target="blank">1000 Design PM</a></li>

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

any idea on how i can have a link open a new window but not use the target tag?

解决方案

You can use JavaScript to open new windows, which avoids the issue of target being invalid in modern HTML.

However, this bypasses various systems people have in place to warn them about new windows (or prevent them from opening) so you are better off using the target attribute (and switching to a Doctype that allows it).

Better still is to leave it to the user to decide when they want a new window. Aside from the annoyance factor, they do introduce accessibility problems.

这篇关于无效的html(href目标标签)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆