解决方案 »

  1.   

    <script>改成&lt;script&gt;可行?
      

  2.   

    直接在js里面改的话,是可以的,但是现在关键是我用select读取数据库出来的$filetext['body']然后转义就是不可以,所以想知道该怎么办
      

  3.   

    $new_content='<P>下面我给大家讲讲javascript函数:</P><PRE class=js name="code"><script> <BR>function show() <BR>{ <BR>alert("hello world"); <BR>} <BR></script></PRE> <P> 结果如图:<BR><IMG title=tu1 alt=tu1 src="uploaded/010P0000240111S5344-1.jpg" width=150 height=150 data-mce-src="uploaded/010P0000240111S5344-1.jpg"></P>';
    echo preg_replace_callback('/<\/?script>/i', function($r){return htmlentities($r[0]);}, $new_content) ;
      

  4.   

    如果是直接用$new_content='<P>下面我给大家讲讲javascript函数:</P><PRE class=js name="code"><script> <BR>function show() <BR>{ <BR>alert("hello world"); <BR>} <BR></script></PRE> <P> 结果如图:<BR><IMG title=tu1 alt=tu1 src="uploaded/010P0000240111S5344-1.jpg" width=150 height=150 data-mce-src="uploaded/010P0000240111S5344-1.jpg"></P>';
    的确是可以的,可是如果$new_content的内容是已经存放在数据库里面了,然后我用select将其读出$filetext['body'],然后再拿来用:
    <textarea id="ajaxfilemanager" name="ajaxfilemanager" style=" height:400px; width:100%;"><?php echo $filetext['body'];?><textarea>
    其中ajaxfilemanager 是tinymce的编辑器
    这样使用,就不可以了,,,
      

  5.   

    代码: <div id="content_entry">
    <?php

    $new_content='<P>下面我给大家讲讲javascript函数:</P><PRE class=js name="code"><script> <BR>function show() <BR>{ <BR>alert("hello world"); <BR>} <BR></script></PRE> <P> 结果如图:<BR><IMG title=tu1 alt=tu1 src="uploaded/010P0000240111S5344-1.jpg" width=150 height=150 data-mce-src="uploaded/010P0000240111S5344-1.jpg"></P>';echo preg_replace_callback('/<\/?script>/i', function($r){return htmlentities($r[0]);}, $new_content) ;        ?>

    <textarea id="ajaxfilemanager" name="ajaxfilemanager" style=" height:400px; width:100%;">
    <?php
    $new_content=$fillrow['body'];echo preg_replace_callback('/<\/?script>/i', function($r){return htmlentities($r[0]);}, $new_content) ;
    ?>
                </textarea>
    </div>
    效果却是:
      

  6.   

    $fillsql="SELECT * FROM entries WHERE id=".$validentry.";";
    $fillres=mysql_query($fillsql)or die("查询错误!".mysql_error());
    $fillrow=mysql_fetch_assoc($fillres);查询数据库返回的内容,具体数据库中存的就是$new_content的内容,见下图大神求解,,,谢谢啦
      

  7.   

    你想要什么效果?把 html 代码放在 textarea 中时应做 html 实体转换:htmlentities
      

  8.   

    10#提醒我了,谢谢啦!!!用你的方法,很好!最后是用的这个进行实体转化 htmlspecialchars ;htmlentities会有乱码!网上查了相关差别!!!谢谢以上所有回答的大牛!!!初学JS还有很多不懂,见谅!