问题如下:
我传了个XML文件给客户端,让其在IE里运行一个小程序来解析XML,这个我做了,我已经拿到了XML文件里的数据,然后要显示在页面上,但是有格式要求,字体要72号绿色,如何解决。<script type="text/javascript">  function test() {………………var str="hellokitty";………………//从XML中拿到数据,都是汉字,utf-8编码
a=strNodes[1].getAttribute("a");
b=strNodes[2].getAttribute("b");
c=strNodes[3].getAttribute("c");………………
str=a+b+c
renturn str;
}
window.onload=function()
  {
  document.getElementsByTagName("p")[0].innerText=text();
  }
</script>
</head><body>
<p></p></body>
现在就是在页面显示的a b c等汉字要让其字体变大  颜色变掉 格式也要变掉,主要是上下三行的结构。
还有XML文件是要刷新的 
数据变掉但是样式不变在线求高手解决

解决方案 »

  1.   

    把字体样式写在<p>里然后把 abc 放在数组里这样可以了吧我没写过JavaScript  就研究了两天求个老师教下我
      

  2.   

    但是还有一个问题我要根据一个从XML里取出来的值 来做图片选择如XML里有个字符取出来是 “上海”那我就要用个上海的图片如果是“南京”就要用南京的图片也要在页面显示的
      

  3.   

    document.getElementsByTagName("p")[0].innerHTML="<font size='10' color='red'>"+test()+"</font>"; var picMap = {"上海":"xx/xx.gif","南京":"yy/yy.jpg"};
      

  4.   

    不能直接返回文本,最好是编辑html动态插入到指定位置
    参考以下思路:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    <script type="text/javascript">
    //html 字符串拼写:字体样式 也可以拼img
    var str1= "<span style='font-size:72px; color:#0C3'>"+ a +"</span>";
    var str2= "<span style='font-size:72px; color:#0C3'>"+ b +"</span>";
    var str3= "<span style='font-size:72px; color:#0C3'>"+ c +"</span>";
    str = str1 + str2 + str3;//最后将拼好的html代码插入指定位置
    document.getElementById("ShowHere").innerHTML = str;
    </script>
    </head>
    <body>
    <div id="ShowHere"></div>
    </body>
    </html>
      

  5.   

    楼上的我试了没显示你有联系方式吗  QQ  msn  你帮我看下我没调试工具  我在记事本上写的谢谢了
      

  6.   

    出现 错误 document.getElementById("ShowHere").innerHTML = str; is null
      

  7.   

    出现 错误 document.getElementById("ShowHere") is null
      

  8.   

    我给的是思路,js和html放在一起了 , 你肯定要根据自己的需要写函数调用的嘛。
    比如:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    <script type="text/javascript">
    var a = "南京";
    var b = "杭州";
    var c = "上海";
    //页面加载完毕执行函数
    function DoShowInfo()
    {
    //html 字符串拼写:字体样式 也可以拼img
    var str1= "<span style='font-size:72px; color:#0C3'>"+ a +"</span>";
    var str2= "<span style='font-size:72px; color:#0C3'>"+ b +"</span>";
    var str3= "<span style='font-size:72px; color:#0C3'>"+ c +"</span>";
    str = str1 + str2 + str3

    //最后将拼好的html代码插入指定位置
    document.getElementById("ShowHere").innerHTML = str;
    }
    </script>
    </head>
    <body onload="DoShowInfo()">
    <div id="ShowHere"></div>
    </body>
    </html>