我可以有< SCRIPT>里面的标签< TABLE&gt ;? [英] Can I have <SCRIPT> tag inside <TABLE>?

查看:102
本文介绍了我可以有< SCRIPT>里面的标签< TABLE&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在表格中添加一个标签,因为PHP会在那里写入一个代码,将代码添加到早期创建的Javascript数组中。然而,我得到一个验证错误(4.01严格)。

有没有什么办法可以做到这一点,还是仅仅禁止像这样的脚本:

 < TABLE> 
< TR>
< SCRIPT>< / SCRIPT>
< TD>
< / TD>
< / TR>
< / TABLE>

(这可能更好吗?):

 <表> 
< TR>
< TD>
< SCRIPT>< / SCRIPT>
< / TD>
< / TR>
< / TABLE>

更改文档类型?你认为什么?

解决方案

SCRIPT 。 org / TR / html4 / struct / tables.html#edef-TRrel =noreferrer> TR 作为 TR 被定义为(TH | TD)+

 <!ELEMENT TR  -  O(TH | TD)+  - 表格行 - > 

这意味着一个或多个元素 TH TD



但是 SCRIPT code> TD 。请参阅 TD 定义$ c $>

 <!ELEMENT(TH | TD) -  O(%flow;)* - 表格标题单元,表格数据单元 - > 

parameter entity flow 定义为:

 <!ENTITY%flow%block; |%inline;> 

inline 定义为:

 <!ENTITY%inline#PCDATA |%fontstyle; |%phrase; |%special; |%formctrl;> 

special 定义为:

 <!ENTITY%special 
A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO>


I got to have a tag inside a table because PHP writes a code there that adds stuff to an earlier created Javascript array. However, I get a validation error (4.01 strict).

Is there any way I can do this or is it simply forbidden to keep a script like this:

<TABLE>
    <TR>
      <SCRIPT></SCRIPT>
        <TD>
        </TD>
    </TR>
</TABLE>

(is this better maybe?):

<TABLE>
    <TR>
        <TD>
         <SCRIPT></SCRIPT>
        </TD>
    </TR>
</TABLE>

Change doctype? What do you think?

解决方案

SCRIPT is not allowed in TR as the content model of TR is defined as (TH|TD)+:

<!ELEMENT TR       - O (TH|TD)+        -- table row -->

That means one or more elements of TH or TD.

But SCRIPT is allowed in TD. See the definition of TD:

<!ELEMENT (TH|TD)  - O (%flow;)*       -- table header cell, table data cell-->

Where the parameter entity flow is defined as:

<!ENTITY % flow "%block; | %inline;">

And inline is defined as:

<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">

And special is define as:

<!ENTITY % special
   "A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">

这篇关于我可以有&lt; SCRIPT&gt;里面的标签&lt; TABLE&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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