IE下自定义标签的问题

大猫钓鱼 2006-10-15 02:36:22
以前没注意,刚发现的,具体如下:

我自定义了一组标签
<menu:tab>
<menu:panel>
<menu:pad>
...

在FF或Opera下无须改动命名空间,直接用:
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
就可以通过

但在IE下,如果照上面的写,自定义标签根本没有加载样式!
于是便有了:
<html xmlns:menu="http://www.w3.org/1999/xhtml" lang="zh-CN">

但这种写法不符合http://www.w3.org/1999/xhtml命名空间下的文档声明,我在http://validator.w3.org/check?uri=referer测试了一下,唯独这个错误解决不了,不知道有没有兄弟知道怎么做?

附错误详细信息:
<html xmlns:menu="http://www.w3.org/1999/xhtml" lang="zh-CN">
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.

其实也不是什么致命问题,只是有些好奇,我在想,javascript里能不能动态加载xmlns,如果这样就可以骗过validator.w3.org的验证了^_^
...全文
427 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hurrayboy 2006-10-18
  • 打赏
  • 举报
回复
都是强人~

UP...
大猫钓鱼 2006-10-17
  • 打赏
  • 举报
回复
OK!谢谢啦^_^
BlueDestiny 2006-10-17
  • 打赏
  • 举报
回复
顺便说一下,如果用document.documentElement.setAttribute("xmlns:menu","www.never-online.net")
在outerHTML里也可以得到我们目的的HTML,但并不把它应用到整个文档。
BlueDestiny 2006-10-17
  • 打赏
  • 举报
回复
不好意思,最近蛮忙的,呵呵,在IE下,可用document.namespaces来做的,在XML里可用createProcessingInstruction方法来追加头

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> - http://www.never-online.net </title>
<style type="text/css" media="all" title="Default">
menu\:item { background-color:#eee; color:blue;}
</style>
<script type="text/javascript">
//<![CDATA[
var a = document.documentElement;
var o = document.namespaces.add("menu","www.never-online.net")
alert(a.outerHTML)
//]]>
</script>
</head>
<body id="www.never-online.net">
<menu:item>BlueDestiny</menu:item>
</body>
</html>
大猫钓鱼 2006-10-16
  • 打赏
  • 举报
回复
现在没办法呀,只能在html里做^_^
大猫钓鱼 2006-10-16
  • 打赏
  • 举报
回复
效果一样
PaulLeder 2006-10-16
  • 打赏
  • 举报
回复
再加入一个命民空间吧
btbtd 2006-10-15
  • 打赏
  • 举报
回复
要不就 xml+xsl, 在 html 里定义这些不怎么爽.
大猫钓鱼 2006-10-15
  • 打赏
  • 举报
回复
今天是周末,顶一下吧

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧