名称属性不是XHTML有效 [英] Name attribute not XHTML valid

查看:63
本文介绍了名称属性不是XHTML有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一些javascript跳转菜单的代码...用

HTML 4.0验证但现在不用XHTML严格1.0验证。


我用过在我的代码中命名属性,暂时不允许

现在。我花了一整天的时间试图找出一个没有运气的解决方案。我已经尝试过document.forms [0]以及其他各种各样的东西,但是

并不知道如何处理它们并且无法让它们工作到
。下面我将向您展示我当前的代码以及w3c.org

验证器的用法。如果有人可以为我更改此代码

XHTML有效,我将非常感激。


------------ -------------

我的HTML


< form name =" jump" action ="">

< script type =" text / javascript">

function jumpMenu(){

location = document.jump.menu.options [document.jump.menu.selectedIndex] .value;

}

< / script>

< select name =" menu"

style =" font-family:''Verdana''; color:#000000; background-color:#99CCFF; font-size:10pt; ">

< option value =" index.html"> HOME< / option>

< option value =" about.html"> ;关于我们< / option>

< option value ="#"> -----------------< / option>

< option value =" showroom.html"> Show Room< / option>

< option value =" dining.html"> -Dining< / option>

< option value =" prints.html"> -Prints< / option>

< option value =" mirrors.html"> ; -Mirrors< / option>

< option value =" accessorie s.html"> -Accessories< / option>

< option value =" lighting.html"> -Lighting< / option>

< option value ="#"> -----------------< / option>

< option value =" glazing.html" >上釉& amp;寄宿< /选项>

<选项价值=" laminated.html">层压玻璃< / option>

< option value =" processing.html" ;>处理< /选项>

<选项值=" design.html">设计< /选项>

< option value ="染色.html">染色& amp;含铅< /选项>

< option value ="#"> -----------------< / option>

< option value =" contact.html">联系我们< / option>

< / select>

< a href = javascript :jumpMenu();">< img src =" go.jpg" alt =" Go!"

/>< / a>

< / form>


- -----------------


w3c验证器结果

第51行第13栏:没有属性name


< form name =" jump" action ="">


您在文档中使用了上面提到的属性,但您使用的

文档类型不支持这个

元素的属性。此错误通常是由于使用框架的文档错误地使用严格

文档类型引起的(例如,您必须使用

Transitional文档类型获得目标属性),或者使用供应商专有扩展(例如marginheight)来获得b&b属性。 (这是

通常通过使用CSS来实现所需的效果)。


如果<不支持元素本身,也可能导致此错误br />
您正在使用的文档类型,因为未定义的元素将没有

支持的属性;在这种情况下,请参阅元素未定义错误

消息以获取更多信息。


如何修复:检查元素和属性的拼写和大小写,

(记住XHTML都是小写的)和/或检查它们是否在所选文档类型中允许

,和/或使用CSS代替此

属性。


第57行,第108栏:文档类型不允许元素select

here;缺少p,h1,h2,h3,h4,h5,h6,div,
$ b $中的一个bpre,address,fieldset,ins,del等。开始标签


.... ground-color:#99CCFF; font-size:10pt;">


元素不允许出现在

你放置它的上下文中;其他提到的元素是唯一允许

存在的元素,并且可以包含所提到的元素。这个

可能意味着你需要一个包含元素,或者你可能忘记关闭前一个元素。


此消息的一个可能原因是您试图将

a块级元素(例如< p>或< table>)放入内联

元素(例如< a>","< span>"或<< font>")。

第76行,第36列:文档类型不允许元素a。这里;

缺少p,h1,h2,h3,h4,h5,h6,中的一个。 div,pre,

地址,字段集,ins,del等开始标记


< a href =" javascript :jumpMenu();">< img src =" go.jpg" ALT ="!去" />< / a>


------------------------------ ---------------


提前致谢


Daniel Callus

Hi. I have some code for a javascript jump menu... It validated with
HTML 4.0 but now does not validate with XHTML strict 1.0.

I have used name atributes in my code which aparantly are not allowed
now. I have spent all day trying to figure out a solution with no
luck. I have tried document.forms[0] and various other things but
havent known exactly what to do with them and couldn''t get them to
work. Below I will show you my current code and what the w3c.org
validator comes up with. If someone could change this code for me to
be XHTML valid I would be very grateful.

-------------------------
My HTML

<form name="jump" action ="">
<script type="text/javascript">
function jumpMenu(){
location=document.jump.menu.options[document.jump.menu.selectedIndex].value;
}
</script>
<select name="menu"
style="font-family:''Verdana'';color:#000000;background-color:#99CCFF;font-size:10pt;">
<option value="index.html">HOME</option>
<option value="about.html">About Us</option>
<option value="#">-----------------</option>
<option value="showroom.html">Show Room</option>
<option value="dining.html">-Dining</option>
<option value="prints.html">-Prints</option>
<option value="mirrors.html">-Mirrors</option>
<option value="accessories.html">-Accessories</option>
<option value="lighting.html">-Lighting</option>
<option value="#">-----------------</option>
<option value="glazing.html">Glazing &amp; Boarding</option>
<option value="laminated.html">Laminated Glass</option>
<option value="processing.html">Processing</option>
<option value="design.html">Design</option>
<option value="stained.html">Stained &amp; Leaded</option>
<option value="#">-----------------</option>
<option value="contact.html">Contact Us</option>
</select>
<a href="javascript:jumpMenu();"><img src="go.jpg" alt="Go!"
/></a>
</form>

------------------

w3c validator results
Line 51, column 13: there is no attribute "name"

<form name="jump" action ="">

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).

This error may also result if the element itself is not supported in
the document type you are using, as an undefined element will have no
supported attributes; in this case, see the element-undefined error
message for further information.

How to fix: check the spelling and case of the element and attribute,
(Remember XHTML is all lower-case) and/or check that they are both
allowed in the chosen document type, and/or use CSS instead of this
attribute.

Line 57, column 108: document type does not allow element "select"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag

....ground-color:#99CCFF;font-size:10pt;">

The mentioned element is not allowed to appear in the context in which
you''ve placed it; the other mentioned elements are the only ones that
are both allowed there and can contain the element mentioned. This
might mean that you need a containing element, or possibly that you''ve
forgotten to close a previous element.

One possible cause for this message is that you have attempted to put
a block-level element (such as "<p>" or "<table>") inside an inline
element (such as "<a>", "<span>", or "<font>").
Line 76, column 36: document type does not allow element "a" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

<a href="javascript:jumpMenu();"><img src="go.jpg" alt="Go!" /></a>

---------------------------------------------

Thanks in advance

Daniel Callus

推荐答案

pi********@gmail.com 写道:
pi********@gmail.com wrote:
嗨。我有一些javascript跳转菜单的代码...


不考虑跳转菜单概念的问题;大多数剧本

不是很好。

用HTML 4.0验证


那已经过时了,IIRC,1996 4.01错误修复版本。

我在代码中使用了名称属性,现在暂时不允许使用。
Hi. I have some code for a javascript jump menu...
Leaving aside the problems with the concept of a jump menu; most scripts
aren''t very good.
It validated with HTML 4.0
That was obsoleted in, IIRC, 1996 with the 4.01 bug fix release.
I have used name atributes in my code which aparantly are not allowed
now.




名称用于表单控件,并指定服务器端处理的内容。你b $ b应该看客户端的id属性。


我建议你去看看 http://www.cs.tut.fi/~jkorpela/forms/navmenu.html

有你的工作代码。

-

David Dorward< http://blog.dorward.me.uk/> ; < http://dorward.me.uk/>

首页是〜/ .bashrc的位置



Name is for form controls and specifies stuff for server side handling. You
should be looking at the id attribute for client side stuff.

I suggest you go and read http://www.cs.tut.fi/~jkorpela/forms/navmenu.html
which has working code for you.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


2005年4月7日13:48:35 -0700, pi********@gmail.com 写道:
On 7 Apr 2005 13:48:35 -0700, pi********@gmail.com wrote:
嗨。我有一些javascript跳转菜单的代码......用HTML 4.0验证,但现在不用XHTML严格1.0验证。
Hi. I have some code for a javascript jump menu... It validated with
HTML 4.0 but now does not validate with XHTML strict 1.0.




所以使用过滤DTD,这就是它的用途。


或者去阅读W3C精确提供的巨大音符

这个问题。
http:// www。 w3.org/TR/xhtml1/diffs.html#h-4.10

不知道TR井的人(如果不是从里到外)没有

业务尝试创作严格的DTD。



So use the fecking Transitional DTD, that''s what it''s there for.

Or go and read the enormous great note the W3C provide on precisely
this issue.
http://www.w3.org/TR/xhtml1/diffs.html#h-4.10
People who don''t know the TR "well" (if not inside-out) have no
business trying to author to the Strict DTD.


David Dorward< do *****@yahoo.com>写道:
David Dorward <do*****@yahoo.com> wrote:
pi ******** @ gmail.com 写道:
pi********@gmail.com wrote:
嗨。我有一些javascript跳转菜单的代码...
暂且不谈跳转菜单的概念;大多数
脚本都不是很好。
Hi. I have some code for a javascript jump menu...
Leaving aside the problems with the concept of a jump menu; most
scripts aren''t very good.




发布的片段说明了许多基本缺陷

使用下拉菜单而不是HTML中的链接列表的想法,

该片段甚至表现出我没有想到的缺陷,例如

<选项值="#"> -----------------< / option>

这听起来很糟糕,如果可以使用的话菜单在一个

语音用户代理上。



The snippet that was posted illustrates many of the fundamental flaws
in the idea of using a pulldown menu instead of a link list in HTML,
the snippet even exhibits flaws that I didn''t think of, such as
<option value="#">-----------------</option>
which is really awful to listen to, if you can use the "menu" on a
speech-based user agent at all.

用HTML 4.0验证
It validated with HTML 4.0



在IIRC,1996年已经淘汰了4.01错误修复版本。



That was obsoleted in, IIRC, 1996 with the 4.01 bug fix release.




不,反过来了:HTML 4.01添加了NAME属性,

在HTML 4.0中不存在,然后XHTML再次将其删除。

OP可能意味着该页面在HTML 4.01下验证。

名称用于表单控件,并指定服务器端处理的内容。您应该查看客户端
内容的id属性。



No, it was the other way round: HTML 4.01 added the NAME attribute,
which wasn''t present in HTML 4.0, and then XHTML took it away again.
The OP probably meant that the page validated under HTML 4.01.
Name is for form controls and specifies stuff for server side
handling. You should be looking at the id attribute for client side
stuff.




在客户端有不同的方式引用FORM元素

代码,包括document.forms [0](假设它是

页面上的唯一表单),这是遗留的JavaScript和document.getElementById(...) ,

这是现代代码(并不适用于古代浏览器)。

人们在FORM中使用NAME属性主要是出于他们学习的习惯
$ b来自某个地方的$ b,如果你的页面有很多

的旧式代码,这是相当无害的 - 但尝试转换这样的
$是没有意义的b $ b页面转换成XHTML,除了可能完全重新设计(甚至

完全重新设计最好在HTML 4.01 Strict中完成,这可以是

后来机械转换为XHTML如果需要的话。


-

Yucca, http:/ /www.cs.tut.fi/~jkorpela/

关于网页制作的网页: http://www.cs.tut.fi/~jkorpela/www.html



There are different ways of referring to a FORM element in client-side
code, including document.forms[0] (assuming it''s the only form on a
page), which is legacy JavaScript, and document.getElementById(...),
which is modern code (and does not work on ancient browsers).
People use the NAME attribute in FORM mostly out of habit they learned
from somewhere, and that''s fairly harmless if you have a page with lots
of old style code anyway - but it''s pointless to try to convert such a
page into XHTML, except perhaps in a complete redesign (and even
complete redesign is better done in HTML 4.01 Strict, which can be
later converted to XHTML mechanically if needed).

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


这篇关于名称属性不是XHTML有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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