这个地方应该是yy.innerHTML。
outerHTML是改变包括yy在内的HTML标签。innerHTML改变内部。OK?

解决方案 »

  1.   

    yy.outerHTML=s   =>yy.innerHTML=s
      

  2.   

    各位都做做实验好吗?
    什么innerHTML、outerHTML、insertAdjacentHTML
    我全试过了!
    我保证本问题堪称年度最难问题!!
      

  3.   

    你的脚本有一个地方有错
    s+= '<script>bb.innerText="xxx" function ff(){return "ff"}<'+'/script>'
    ==〉
    s+= '<scr'+'ipt>bb.innerText="xxx" function ff(){return "ff"}<'+'/script>'tyr again
      

  4.   

    不对,问题不是这么简单。
    即使是这个样子:
    s="<div id=bb>aa</div>"
    s+="<style>#bb{font:19pt}</style>"
    css也没有起作用!
      

  5.   

    为什么样式一定要这样定义呢?你不可以把塌方到头上<head> 部分,或直接写在<div>中吗?你这样做的目的是什么?这种写法很少见
      

  6.   

    zhjzh_zjz:
    我想实现网页的加载,也就是实现类似asp的<include>元素。
    明白?看一下我的程序吧
    http://expert.csdn.net/Expert/topic/1608/1608337.xml?temp=.7844507xinyunyishui(心云意水):
    没准是版本问题,我的是ie6 sp1
      

  7.   

    <body>
    <div id=xx>
    <div id=yy>
        <div id=aa>aa</div>
        <script>aa.innerText='xx'</script>
    </div>
    </div>
    <script>
    alert(xx.innerHTML)
    s="<div id=bb>aa</div>"
    a="<style>#bb{font:19pt;color:red}</style>"//还有这里,应该是在head里面的,所以用document.write
    a+= "<s"+"cript>bb.innerText='xxx';function ff(){return 'ff'}</"+"script>"//这里错了
    alert(s)
    yy.outerHTML=s
    document.write(a)
    alert(bb.outerHTML)
    alert(ff())
    </script>
    </body>
      

  8.   

    你那个我收藏起来还没来得及仔细研究。我再看看。我的一个贴字,不只能否对你有所帮助
    http://expert.csdn.net/Expert/topic/1556/1556452.xml?temp=4.911441E-02
      

  9.   

    fason(阿信) :
    看来<div>里面不能嵌套CSS和SCRIPT了?
    可是手工添加怎么就可以?看来我想实现加载,还得将脚本和CSS过滤出来,单独拿document.write写进去?
      

  10.   

    样式是可以的,但脚本不可以
    上面
    s="<div id=bb>aa</div>"
    s+="<style>#bb{font:19pt;color:red}</style>"//还是可以的
      

  11.   

    但是我不能保证用户都将css写在html的后面呀?
    再说,过滤也是个很麻烦的事,非常麻烦!
      

  12.   

    注意指定<script>的defer属性!!!
    代码如下:
    ---------------------------------------------<div id=xx>
    <div id=yy>
        <div id=aa>aa</div>
        <style>#aa  {font:14pt}</style>
        <script defer>aa.innerText='xx'</script>
    </div>
    </div>
    <script>
    alert(xx.innerHTML)
    s="<div id=bb>aa</div>"
    s+="<style>#bb{font:19pt}</style>"
    s+= '<script defer>bb.innerText="xxx";function ff(){return "ff"}<'+'/script>'
    alert(s)
    yy.outerHTML=s
    alert(xx.innerHTML)
    alert(ff())
    </script>
      

  13.   

    <body>
    <div id=xx>
    <div id=yy>
        <div id=aa>aa</div>
        <script>aa.innerText='xx'</script>
    </div>
    </div>
    <script>
    alert(xx.innerHTML)
    s="<div id=bb>aa</div>"
    s+="<style>#bb{font:9pt;color:red}</style>"
    a= "<s"+"cript>bb.innerText='xxx';function ff(){return 'ff'}</"+"script>"
    yy.outerHTML=s
    document.write(a)
    alert(ff())
    </script>
    </body>
      

  14.   

    学习,终于知道了defer,可以不等待实时脚本的执行,继续加载其它的
      

  15.   

    <script>
    alert(xx.innerHTML)
    s="<div id=bb>aa</div>"
    s+="<style>#bb{font:9pt;color:red}</style>"
    s+= "<script defer>bb.innerText='xxx';function ff(){return 'ff'}</"+"script>"
    yy.outerHTML=s
    alert(ff())
    </script>
      

  16.   

    defer:
    Indicates the script block contains only functions and no in-line script. Deferring the parsing of scripts until they are needed can improve performance by decreasing the time it takes to load a document.
    又学了一招!
    不过能否不限制客户端的使用,而在加载端进行处理?
      

  17.   

    判断很难啦
    假如用户程序里有
    <script>
    s='<style></style>'
    </script>
    ??
      

  18.   

    ssm1226:
    我想实现网页的加载,也就是实现类似asp的<include>元素。
    看一下我的程序吧
    http://expert.csdn.net/Expert/topic/1608/1608337.xml?temp=.7844507
      

  19.   

    运行时添加的脚本块必须调用一次window.execScript(sExpression, sLanguage)
    运行时添加css可以通过<STYLE>
    BODY {background-color: #CFCFCF;}
    @import url("otherStyleSheet.css");
    </STYLE>
    <SCRIPT>
    window.onload=fnInit;
    function fnInit(){
       // Access a rule in the styleSheet, change backgroundColor to blue.
       var oStyleSheet=document.styleSheets[0];
       var oRule=oStyleSheet.rules[0];
       oRule.style.backgroundColor="#0000FF";
       // Add a rule for P elements to have yellow backgrounds.
       oStyleSheet.addRule("P","background-color: #FFFF00;");
       // Change and imported rule:
       oStyleSheet.imports[0].color="#000000";
    }
    </SCRIPT>
      

  20.   

    谢谢大家!
      感谢xinyunyishui(心云意水)、fason(阿信)、 ssm1226(雨中人) 、yonghengdizhen(生命过去了四分之一个世纪,我依然是我) 提出了非常好的方法。也感谢其他人的支持参与。
      梅花雨大哥好像看不起我,我提的两个问题请梅花雨回答,都不理我!!!!  让帖子再呆几天吧,我想再看看还有没有高人的高见。
      

  21.   

    你的问题
    以前因为window.open会异步执行,而做过同步加载网页
    也面临这样的问题。解决办法,以上阐述过了,只有defer或execScript最终采用的是execScript,因为没有(inline script的js是很少的)
    execScript可以确保正确
      

  22.   

    大家到这里看看,
    http://www.solarstones.com/wzq/
    我第一次写的,帮我测试一下好吗?
      

  23.   

    还有样式表单,放到调用的地方
    <style>
    A.banner:link { COLOR: #ffff77; TEXT-DECORATION: none}
    A.banner:visited { COLOR: #ffff99; TEXT-DECORATION: none}
    A.banner:active { COLOR: #ffff77; TEXT-DECORATION: none}
    A.banner:hover { COLOR: #ffffff; TEXT-DECORATION: none;background-color:#6090ff}
    td.Menu_MItem1 {padding:3;border:solid 1px #f4faff;border-right:none;font:9pt;cursor:hand;white-space:nowrap}
    td.Menu_MItem2 {padding:3;border:solid 1px #f4faff;border-left:none;font:9pt;cursor:hand}
    td.Menu_MItem1o {padding:3;border:solid 1px #6060a0;border-right:none;background-color:#ffdd88;font:9pt;cursor:hand;white-space:nowrap}
    td.Menu_MItem2o {padding:3;border:solid 1px #6060a0;border-left:none;background-color:#ffdd88;font:9pt;cursor:hand}
    div.Menu_MPanel {POSITION:absolute;border:outset 1px #8080ff;}
    div.Menu_MPanel2{background-color:#f4faff;border-left:solid 8px #8080ff;padding:2}
    .Menu_MInner {}
    </style>