简体   繁体   English

W3失败了 <noscript> 嵌套在DIV标签中

[英]W3 Failing with <noscript> nested in a DIV tag

I've got my application working great, however I'd LOVE to be able to have it validate completely on W3. 我的应用程序运行良好,但我很乐意能够在W3上完全验证它。

My problem is quite simple. 我的问题很简单。 I'm using the Bing JS API to attach a Bing Map to a Div tag. 我正在使用Bing JS API将Bing Map附加到Div标签。 Within that Div tag, I have a <noscript> element that calls the MultiMap static map provider IF javascript is disabled. 在该Div标签内,我有一个<noscript>元素,可以调用MultiMap静态地图提供程序,如果禁用了javascript。 The reason I've chosen to do it this way is because I don't want to call the MultiMap API if I'm not going to actually use it. 我选择这样做的原因是因为如果我不打算实际使用它,我不想调用MultiMap API。

Is there an alternative way to do this so that I can be W3 HTML5 valid? 是否有另一种方法可以使W3 HTML5有效?

<div id='bingMap' class="largeMap">
    <noscript>
        <img src="http://developer.multimap.com/API/map/1.2/xxxxxxxxxxxxxxx?zoomFactor=11&amp;width=550&amp;height=400&amp;lat_1=51.18468&amp;lon_1=-114.497999&amp;lat_2=51.169858&amp;lon_2=-114.32549&amp;lat_3=51.083277&amp;lon_3=-114.203964&amp;lat_4=51.063097&amp;lon_4=-114.092031&amp;lat_5=50.939664&amp;lon_5=-113.973568" />
    </noscript>
</div>

This perhaps: 这可能是:

<html>
<body>
  <script type="text/javascript">
    document.write("<" + "!--");
  </script>
  <p>This will be commented out if scripting is supported.</p>
  <script type="text/javascript">
    document.write("-" + "->");
  </script>
</body>
</html>

wrap the <img/> into a div, p or another block-element. <img/>包装成div,p或其他块元素。 <noscript> is only allowed to have block-elements as direct child. <noscript>只允许将block-elements作为直接子元素。

<div id='bingMap' class="largeMap">
    <noscript>
        <div>
            <img src="....." />
        </div>
    </noscript>
</div>

I would suggest taking out the xmlns in order to prevent it from interpreting your code as XHTML5 (as opposed to HTML5) as XHTML5 is just a stricter version of HTML5 disallowing many features. 我建议取出xmlns以防止它将您的代码解释为XHTML5(而不是HTML5),因为XHTML5只是一个更严格的HTML5版本,不允许使用许多功能。 HTML5 still supports XHTML-style tags, so no loss. HTML5仍然支持XHTML样式的标签,所以没有损失。

Something like the following would work: 像下面这样的东西会起作用:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>title</title>
  </head>
  <body>
    <div id="bingMap" class="largeMap">
      <noscript>
        <img alt="" src="http://developer.multimap.com/API/map/1.2/xxxxxxxxxxxxxxx?zoomFactor=11&amp;width=550&amp;height=400&amp;lat_1=51.18468&amp;lon_1=-114.497999&amp;lat_2=51.169858&amp;lon_2=-114.32549&amp;lat_3=51.083277&amp;lon_3=-114.203964&amp;lat_4=51.063097&amp;lon_4=-114.092031&amp;lat_5=50.939664&amp;lon_5=-113.973568" />
      </noscript>
    </div>
  </body>
</html>

The following validates for me at http://validator.w3.org/check 以下内容通过http://validator.w3.org/check验证

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC
  "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>title</title>
    <meta http-equiv="content-type" 
        content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
</head>
<body>

<div id='bingMap' class="largeMap">
    <noscript>
      <div>
        <img alt="" src="http://developer.multimap.com/API/map/1.2/xxxxxxxxxxxxxxx?zoomFactor=11&amp;width=550&amp;height=400&amp;lat_1=51.18468&amp;lon_1=-114.497999&amp;lat_2=51.169858&amp;lon_2=-114.32549&amp;lat_3=51.083277&amp;lon_3=-114.203964&amp;lat_4=51.063097&amp;lon_4=-114.092031&amp;lat_5=50.939664&amp;lon_5=-113.973568" />
      </div>
    </noscript>
</div>

</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM