<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
  <!-- 中部右边start -->这些要读取的代码<!-- 中部右边stop-->
</body>
</html>
就是要用js取出 <!-- 中部右边start -->和<!-- 中部右边stop-->这两个标签的数据 

解决方案 »

  1.   

    document.getElementById('start').innerHTML
    document.getElementById('stop').innerHTML
      

  2.   

    方案1:使用document.getElementsByTagName(‘!’), 这时候的节点名字是一个感叹号,但是这种方法只适合于ie浏览器,firefox不支持方案2:使用document.body.childNodes遍历找到nodeName是“#comment”的节点就是注释节点,可以通过nodeValue的不同区别不同的注释,例如注释是:<!—some string-->那么nodeValue就是some string。
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>    <script type="text/javascript">    //<![CDATA[        window.onload = function ()
            {
                var node = document.body.lastChild.previousSibling.previousSibling;
                alert(node.nodeValue);
            }    //]]></script></head>
    <body>
    <!-- 中部右边start -->这些要读取的代码<!-- 中部右边stop-->
    </body>
    </html>
      

  4.   

    var reg = /<!--\s*[\u4e00-\u9fa5\w]*\s*-->([\w\W]*?)<!--\s*[\u4e00-\u9fa5\w]*\s*-->/g,match = reg.exec(document.getElementsByTagName("body")[0].innerHTML);
    if(match){
    alert(match[1]);
    }
      

  5.   

    var reg = /<!--\s*([\u4e00-\u9fa5\w]*)\s*start\s*-->([\w\W]*?)<!--\s*\1\s*stop\s*-->/gi,match = reg.exec(document.getElementsByTagName("body")[0].innerHTML);
    if(match){
    alert(match[2]);
    }