我就是对javascript不是很熟悉才来请教大家,特别是不能破坏html的结构 没有什么头绪? 能够提示一下这个不能破坏html结构的思路啊?

解决方案 »

  1.   

    我看很多人做不出来   我这里找到一些资料
    http://www.never-online.net/blog/article.asp?id=113
    大家一起研究一下!
      

  2.   

    读文件用Fso:基本用法 var fso = new ActiveXObject("Scripting.FileSystemObject"); (其他不知道的去baidu上搜索)当你读到数据后,再用 document.getElementById("content").value=你读到的东西基本思路很简单,自己动手做做,不会再来说,这样才有人会帮你
      

  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>
    <script language="javascript">
    function getLenght()
    {return document.getElementById("content").value.length;
    }
    //混合内容
    function mixContent()
    {
    var j=0;
    var mixStr;
    var Rndn;
    while(i<5){
    mixStr=getContent();
    Rndn=Math.floor(Math.random()*getLenght()+1); 
    mixStr=mixStr.substring(0,Rndn)+getInsertContent()+mixStr.substring(Rndn,getLenght());
    }
    document.getElementById("content").value=mixStr;
    }
    //获取Content里面本来有的内容
    function getContent()
    {
    return document.getElementById("content").value;
    }//获取要插入行数据
    function getInsertContent()
    {
    var fText;
    var RndNum;
    var i=0;
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    txtFile = fso.OpenTextFile("insert.txt", 1, false, 0);
    RndNum=Math.floor(Math.random()*5+1); //5条测试
    while (i<=RndNum)
    {
    txtFile.SkipLine();
    }
    fText += txtFile.ReadLine();
    return fText
    txtFile.Close();
    fso = null
    }</script>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Test</title>
    </head><body>
    <form id="form1" name="form1" method="post" action="">
      
      <textarea id="content" cols="137" rows="20" name="textarea"></textarea>
      <input name="mix"  id="mix" type="button"   value="混合" onclick="mixContent()"   />
    </form>
    </body>
    </html>
    简单的我也是可以写出来的  但是就是得不到想要的效果
      

  4.   

    <!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>
    <script language="javascript">
    function getLenght()
    {return document.getElementById("content").value.length;
    }
    //混合内容
    function mixContent()
    {
    var j=0;
    var mixStr;
    var Rndn;
    while(i<5){
    mixStr=getContent();
    Rndn=Math.floor(Math.random()*getLenght()+1); 
    mixStr=mixStr.substring(0,Rndn)+getInsertContent()+mixStr.substring(Rndn,getLenght());
    }
    document.getElementById("content").value=mixStr;
    }
    //获取Content里面本来有的内容
    function getContent()
    {
    return document.getElementById("content").value;
    }//获取要插入行数据
    function getInsertContent()
    {
    var fText;
    var RndNum;
    var i=0;
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    txtFile = fso.OpenTextFile("insert.txt", 1, false, 0);
    RndNum=Math.floor(Math.random()*5+1); //5条测试
    while (i<=RndNum)
    {
    txtFile.SkipLine();
    }
    fText += txtFile.ReadLine();
    return fText
    txtFile.Close();
    fso = null
    }</script>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Test</title>
    </head><body>
    <form id="form1" name="form1" method="post" action="">
      
      <textarea id="content" cols="137" rows="20" name="textarea"></textarea>
      <input name="mix"  id="mix" type="button"   value="混合" onclick="mixContent()"   />
    </form>
    </body>
    </html>
    简单的我也是可以写出来的  但是就是得不到想要的效果
      

  5.   


    while (i<=RndNum)
    {
        txtFile.SkipLine();//i没变化,会死循环的
    }
    fText += txtFile.ReadLine();
    return fText;//在这里return了,后面的close就没意义了
    txtFile.Close();//移到return前面去
    fso = null;//移到return前面去
      

  6.   

    <!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>
    <script language="javascript">
    function getLenght()
    {return document.getElementById("content").value.length;
    }
    //混合内容
    function mixContent()
    {
    var j=0;
    var mixStr;
    var Rndn;
    while(j<5){
    mixStr=getContent();
    Rndn=Math.floor(Math.random()*getLenght()+1); 
    mixStr=mixStr.substring(0,Rndn)+getInsertContent()+mixStr.substring(Rndn,getLenght());
    j+=1;
    }
    document.getElementById("content").value=mixStr;
    }
    //获取Content里面本来有的内容
    function getContent()
    {
    return document.getElementById("content").value;
    }//获取要插入行数据
    function getInsertContent()
    {
    var fText;
    var RndNum;
    var i=0;
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    txtFile = fso.OpenTextFile("insert.txt", 1, false, 0);
    RndNum=Math.floor(Math.random()*5+1); //5条测试
    while (i<=RndNum)
    {
    i+=1;
    txtFile.SkipLine();
    }
    fText += txtFile.ReadLine();
    txtFile.Close();
    fso = null
    return fText}</script>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Test</title>
    </head><body>
    <form id="form1" name="form1" method="post" action="">
      
      <textarea id="content" cols="137" rows="20" name="textarea"></textarea>
      <input name="mix"  id="mix" type="button"   value="混合" onclick="mixContent()"   />
    </form>
    </body>
    </html>
    大头虾!忘了
      但是为什么我在 firebug中调试显示一下错误?
    ActiveXObject is not defined
    getInsertContent()Untitled-1.html (行 36)
    mixContent()Untitled-1.html (行 19)
    onclick(click clientX=41, clientY=294)mbh6XUrh...39w%3D%3D (行 2)
    [Break on this error] var fso = new ActiveXObject("Scripting.FileSystemObject");
      

  7.   

    但是为什么我在 firebug中调试显示一下错误? 因为firefox是不支持activexobject的,IE专用
      

  8.   

    那要写个通用的方法  那在f仅irefox可用 那怎么写?
      

  9.   

    有没有好的调试方案啊!javascript的调试实在是太烦了 自己对javacsript也不是很熟悉!
      

  10.   


    不知道你有没有安装visual studio,在IE中开启javascript调试,然后在需要调试的地方,加上debugger;就会调用vs来进行JS调试了,JS出错也会调用
      

  11.   

    alert( fText);//  弹出窗口undefined4
    RndNum=Math.floor(Math.random()*2+1); //2条测试  修改了 可以运行 但是为什么是undefined4
    我的txt文件是
    1
    2
    3
    4
    5
      

  12.   

    我自己搞定了 可以基本实现 但是 还是没有想到 可以不破坏html机构的方法!
      

  13.   

    读本地文件就存在权限问题,没意义ie可以使用activex,会有安全提示ff应该读不了
    不破坏html机构的方法!
    ---------
    什么意思??
      

  14.   

    FSO 使用介绍以及例子我在前些时候在论坛上多次发帖,已经帮别人解决了,首先你想用静态代码来操作本地文件上就会存在很大的 IE 权限问题,设置 FSO ,首先将浏览器安全权限设为低,其次还要设置浏览器的 跨域访问权限具体例子和设置原理请参照我的另一封帖子,我是真的不想再写了。。http://topic.csdn.net/u/20080908/09/1d9e9cd3-8dca-46ad-a722-3ae88d5301af.html