function y()
{
var a = document.all || document.getElementsByTagName("*");
for(i=0;i<a.length;i++)a[i].style.color = 'red';
}

解决方案 »

  1.   

    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    document.body.innerHTML=document.body.innerHTML.replace(/(祝大家中秋节快乐!!!)/g,"<span style='color:red'>$1</span>")
    }
    </script>
    </body>
      

  2.   

    xinyunyishui(心云意水)的这个弓虽!
      

  3.   

    好像少几个字符?……
    function y()
    {var o=document.body;
     o.innerHTML=o.innerHTML.replace(/(祝大家中秋节快乐!!!)/g,"<span style='color:red'>$1</span>")
    }霍霍~~没玩过Mozilla,让老大们见效
    祝两位老大中秋快乐
      

  4.   

    呀!
    笨了!发现老大给Body加了id……
    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {x.innerHTML=x.innerHTML.replace(/(祝大家中秋节快乐!!!)/g,"<span style='color:red'>$1</span>")
    }
    </script>
    </body>ps:楼上的见效改为见笑……
      

  5.   

    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    var a = document.all || document.getElementsByTagName("*");
    for(i=0;i<a.length;i++)a[i].style.color = 'red';
    }</script>
    </body>
      

  6.   

    function y()
    {
      document.body.style.color = "red";
    }
    勉强可以
      

  7.   

    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    var netLove = document.all;
    for(i=0;i<netLove.length;i++)
    {
    netLove[i].style.color = "red"
    }
    }
    </script>
    </body>
      

  8.   

    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    document.body.style.color='red';
    }
    </script>
    </body>
      

  9.   

    恩,受到启发
    难道
    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    x.style.color='red';
    }
    </script>
    </body>
    ……………………
    不知道Mozilla行不行
      

  10.   

    <body id="x" onClick="y()">
    <a>祝大家中秋节快乐!!!</a> 
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    x.text = "red";
    }
    </script>
    </body>
    看来是我的最短啦~~~
      

  11.   

    <body id="x" onclick="y()">
    <a id=a1>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    //在这里写代码,实现目标:在页面上点击鼠标,把页面上的所有文字的颜色变成红色,
      for (var i=0;i<document.all.length;i++)
      {
        document.all(i).style.color = 'red';
      }
    }
    </script>
    </body>
      

  12.   

    vbs循环简短:)<body id="x" onclick="vbs:y">
    <a>祝老大和大家中秋节快乐!!!</a>
    <div>祝老大和大家中秋节快乐!!!</div>
    <p>祝老大和大家中秋节快乐!!!</p>
    <h3>祝老大和大家中秋节快乐!!!</h3>
    </body>
    <script language="vbs">
    sub y()  
    for each netLove in document.all  
        netLove.style.color = "red"
    next
     end sub
    </script>
    </body>
      

  13.   

    Mozilla没用过,不知道我那段代码能执行通不能,我是查了HTML标准,写的代码~~~
      

  14.   

    我觉得这道题最简单的做来是用样式表解决, 而不应该用循环定义每个element
    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    <style></style>
    <script language="javascript">
    function y()
    {
      document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
    }
    </script>
    </body>
      

  15.   

    我觉得这道题最简单的做来是用样式表解决, 而不应该用循环定义每个element
    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    <style></style>
    <script language="javascript">
    function y()
    {
      document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
    }
    </script>
    </body>
      

  16.   

    严重抄袭mikespook(懒猫开始新生活)中:为节省空间,放弃空格分号等等……
    document.body.text='red'
      

  17.   

    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    </body>
    <script>
    function y()
    {
    document.fgColor = "red";
    //在这里写代码,实现目标:在页面上点击鼠标,把页面上的所有文字的颜色变成红色,
    }
    </script>
    </body>
      

  18.   

    <div style="color: blue">祝大家中秋节快乐!!!</div>
    <p style="color: green">祝大家中秋节快乐!!!</p>对于这些已经定义过字体颜色的对象, 通过定义BODY的fgColor, style.color 等等方法都是无用的!
      

  19.   

    meizz,因时因地,这里却是不违反题意的,呵呵很久没看到大家了,祝大家中秋快乐!团团圆圆
      

  20.   

    回复人: meizz(梅花雪 1+1=3) ( ) 信誉:694  2004-09-28 15:24:00  得分: 0  
     
     
       <div style="color: blue">祝大家中秋节快乐!!!</div>
    <p style="color: green">祝大家中秋节快乐!!!</p>对于这些已经定义过字体颜色的对象, 通过定义BODY的fgColor, style.color 等等方法都是无用的!
      
    --------------------------------------------------------------------------- 嘿嘿,我们是应试教育的产物~~~只看题,不考虑创新~~~~ ^_^
      

  21.   

    回复人: meizz(梅花雪 1+1=3) ( ) 信誉:694  2004-09-28 14:56:00  得分: 0  
     
     
       我觉得这道题最简单的做来是用样式表解决, 而不应该用循环定义每个element
    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    <style></style>
    <script language="javascript">
    function y()
    {
      document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
    }
    </script>
    </body>
      
     
     回复人: meizz(梅花雪 1+1=3) ( ) 信誉:694  2004-09-28 14:56:00  得分: 0  
     
     
       我觉得这道题最简单的做来是用样式表解决, 而不应该用循环定义每个element
    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    <style></style>
    <script language="javascript">
    function y()
    {
      document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
    }
    </script>
    </body>
    ___________________________________________________________________________严重同意!可惜回家的班车上才想到:(
      

  22.   

    <body id="x" onclick="y()">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3>
    <style></style>
    <script language="javascript">
    function y()
    {
      var o = document.getElementById("x");
    o.style.color='red';
    }
    </script>
    </body>
      

  23.   

    document.createStyleSheet().addRule("*", "color:red");
      

  24.   

    点评:
    1,mikespook(懒猫开始新生活) 是比较好的答案,也是我当初的想法,虽然text在html3.2标准中就已经存在了,但后来已经不推荐使用了,但浏览器仍然都支持的,但是,你的解答在Mozilla里没有效果,应该严格dom的方法进行操作。应该写成document.getElementById("x").text='red'
    2,现在最简捷也最正确的应该是 bencalie(Bencalie) 的了。因此可以得到150分的高分,其它分数属于小礼物
      

  25.   

    document.createStyleSheet().addRule("*", "color:red");在mozilla里行不同。
      

  26.   

    哐铛,晕倒~~~~
    不行,要去找个Mozilla装一下~~~这样下去岂不完蛋~~~
      

  27.   

    孟子, 对于有些已经定义过字体颜色的对象, 设置 document.fgColor 是无效的呀, 根据样式的类继承即可知, 设置fgColor的级别没有直接设置在对象字体上的样式级别高呀, 所以这个方法不能算最好.比如说以下的例子:
    <body id="x" onclick="y()"><span style="color: blue">
    <a>祝大家中秋节快乐!!!</a>
    <div>祝大家中秋节快乐!!!</div>
    <p>祝大家中秋节快乐!!!</p>
    <h3>祝大家中秋节快乐!!!</h3></span>
    </body>
    <script>
    function y()
    {
      document.fgColor = "red";
    }
    </script>这样设置fgColor就已经完全失效了. 所以我认为还是fason的代码最好!! :)
      

  28.   

    function y()
    {
    var a = document.all || document.getElementsByTagName("*");
    for(i=0;i<a.length;i++)a[i].style.color = 'red';
    }
    这个简单,拿来支持
      

  29.   

    function y()
    {
    var a = document.all || document.getElementsByTagName("*");
    for(i=0;i<a.length;i++)a[i].style.color = 'red';
    }
    --------------
    fason的这个好~支持。
      

  30.   

    function y(){
      document.color='red'
    }