2个html文件 1.html 和2.html
1个js文件 ckeditor.js1.html源文件 http://115.47.220.127/1.html
2.html源文件 http://115.47.220.127/2.htmljs 如果需要本地测试的话 http://ckeditor.com/download问题应该在于innerHTML里面的script不能执行.网上看了很多了,但是这种能解决iframe调用的.要求FF,IE都OK!代码请直接贴出来,解决问题的直接留下支付宝.

解决方案 »

  1.   


    1.html<!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>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>1</title>
    </head>
    <body>
    <div id="container">
    <div id="a">
         我需要"iframe打开2.html"和"直接打开2.html"效果一样<br />
    <a href="2.html" target="Iframe">iframe打开2.html</a> <a href="2.html" target="_blank">直接打开2.html</a>
    </div>
    <div id="b">
    </div>
    </div>
    <iframe name="Iframe" src="" width="1000px" height="1000px" frameBorder="0" scrolling="no"></iframe>
    </body>
    </html>
      

  2.   

    2.html
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>2</title>
    <script type="text/javascript">
        function OnLoadIframe() {
            if (window.parent.document.getElementById("b") != undefined) {
                window.parent.document.getElementById("b").innerHTML = document.getElementById("d").innerHTML;
            }
            
        }
    </script>
    <script type="text/javascript">
        window.onload = OnLoadIframe;
    </script>
    </head>
    <body>
    <div id="container">
    <div id="c">
    </div>
    <div id="d">
         <script type="text/javascript" src="http://ckeditor.com/apps/ckeditor/3.6.1/ckeditor.js?1309164514"></script>
         <form>
    <textarea class="ckeditor" name="Content"></textarea>
    </form>
    </div>
    </div>
    </body>
    </html>
      

  3.   

    昏,刚才还没注意到.
    你直接改了iframe的宽度和高度啊.提醒你:我是通过innerHTML来插入的,你这样我直接iframe,不需要innerHTML就行了.
      

  4.   

    你的意思 点击连接 那个b的div 变成编辑器 ?
      

  5.   

    innerHTML插入javascript代码并且马上执行吗?
      

  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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>1</title>
    <style type="text/css">
    .editor{display:none}
    </style>
    <script type="text/javascript" src="http://ckeditor.com/apps/ckeditor/3.6.1/ckeditor.js?1309164514"></script>
    <script type="text/javascript">
    <!--
    window.onload = function(){
    document.getElementById("Content").onclick = function(){
    CKEDITOR.replace("Content")
    }
    }
    //-->
    </script>
    </head>
    <body>
    <div id="container">
    <div id="a">
         我需要"iframe打开2.html"和"直接打开2.html"效果一样<br />
    <a id="Content" href="javascript:;">iframe打开2.html</a>
    </div>
    <textarea name="Content" class="editor"></textarea>
    </div>
    </body>
    </html>
      

  7.   

    刚刚发现链接的id和textarea的name属性如果设置相同的话会有冲突。顺便改了一下代码可以更方便使用,
    只要保持链接的id为init_加上textarea的name值,就可以一次绑定更多的链接功能:
    <div id="container">
    <div>
    <a id="init_Content1" class="initEditor" href="javascript:;">输入内空1</a>&nbsp;
    <a id="init_Content2" class="initEditor" href="javascript:;">输入内空2</a>
    </div>
    <div><textarea name="Content1" class="editor"></textarea></div>
    <div><textarea name="Content2" class="editor"></textarea></div>
    </div>window.onload = function(){
    var editorInitLinks = []
    var links = document.getElementsByTagName("a");
    for(var i=0; i<links.length; i++)
    if(links[i].className == "initEditor")
    editorInitLinks.push(links[i])
    for(var i=0; i<editorInitLinks.length; i++)
    editorInitLinks[i].onclick = function(){CKEDITOR.replace(this.id.substr(5))}
    }
      

  8.   

    [Quote=引用 13 楼 inpool 的回复:]没太明白你的意思.我把你的代码添加到文件中,链接都不能点了
    如果你测试通过了,希望你能提供完整代码.谢谢.
      

  9.   

    成功运行前提:能上网,否则需要把ckeditor下载到本地并更改第一个script标签的src属性。1.html的完整代码(不需要2.html):
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>1</title>
    <style type="text/css">.editor{display:none}</style>
    <script type="text/javascript" src="http://ckeditor.com/apps/ckeditor/3.6.1/ckeditor.js"></script>
    <script type="text/javascript">
    window.onload = function(){
        var editorInitLinks = []
        var links = document.getElementsByTagName("a");
        for(var i=0; i<links.length; i++)
            if(links[i].className == "initEditor")
                editorInitLinks.push(links[i])
        for(var i=0; i<editorInitLinks.length; i++)
            editorInitLinks[i].onclick = function(){CKEDITOR.replace(this.id.substr(5))}
    }
    </script>
    </head>
    <body>
    <div id="container">
        <div>
            <a id="init_Content1" class="initEditor" href="javascript:;">输入内空1</a>&nbsp;
            <a id="init_Content2" class="initEditor" href="javascript:;">输入内空2</a>
        </div>
        <div><textarea name="Content1" class="editor"></textarea></div>
        <div><textarea name="Content2" class="editor"></textarea></div>
    </div>
    </body>
    </html>
      

  10.   

    [Quote=引用 15 楼 inpool 的回复:]你改变我的结构了.1.html和2.html是我从系统里面独立出来方便解决问题的.
      

  11.   

    <script>
               alert('你好啊! ') ;
    </script>
      

  12.   

    2.html
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>2</title>
    <script type="text/javascript">
    function OnLoadIframe()
    {
    //parent.document.getElementById("b").innerHTML=document.getElementById("d").innerHTML;
    var tag=null;
    if(parent !=window.self){
    alert('加载到父窗体');
    tag=parent;
    parent.document.getElementById("b").innerHTML=document.getElementById("d").innerHTML;
    }else{
    alert('不加载到父窗体');
    tag=window;
    } var script=document.createElement('script');
    script.src='http://ckeditor.com/apps/ckeditor/3.6.1/ckeditor.js?1309164514';
    tag.document.getElementsByTagName('head')[0].appendChild(script);
    showEdit(); function showEdit(){
    if(tag.CKEDITOR){
    tag.CKEDITOR.replace('Content1_kk_kk_kk');
    }else{
    setTimeout(  showEdit , 25 );
    }
    }}
    </script>
    <script type="text/javascript">
    window.onload=OnLoadIframe;
    </script>
    </head>
    <body>
    <div id="container">
    <div id="c">
    </div>
    <div id="d">
    <fieldset>
    <legend>我是h2.tml</legend> 
         <form>
    <textarea id='Content1_kk_kk_kk' name="Content1_kk_kk_kk" class="editor" style='display:none;'></textarea>
    </form>
    </fieldset>
    </div>
    </div>
    </body>
    </html>
    有些事情是没有办法的
      

  13.   

    [Quote=引用 20 楼 kk3k2005 的回复:]非常感谢!方便的话直接贴出支付宝账号,或者Q(5-1617-2322)我.
      

  14.   

    还有一个bug,就是第二次点击"iframe打开2.html",不能显示.还望继续解决一下.
      

  15.   

    可以实现需要在 1.html中控制
    不过你的需求描述的不太清楚需要反复打开的话 逻辑也很简单
    你第一次点击是加载 2.html页面 之后 就是切换 <div id='b'></div> 的显示状态难的已经解决了 剩余的自己捣鼓下吧
      

  16.   

    [Quote=引用 23 楼 kk3k2005 的回复:]剩下的对于我也非常难.求帮助.
      

  17.   

    [Quote=引用 20 楼 kk3k2005 的回复:]不行啊.我2.html页面是添加新闻或者修改新闻页面,肯定不止一次需要.问题应该在于第一次加载以后,ckeditor的内容都被innerHTML到1.html这个容器里面了.导致后续的又会继续加载ckeditor到1.html容器里面.求KK3K2005大哥继续帮助小弟.
      

  18.   

    <script type="text/javascript">
    function OnLoadIframe()
    {
    //parent.document.getElementById("b").innerHTML=document.getElementById("d").innerHTML;
        var tag=null;
        if(parent !=window.self){
            alert('加载到父窗体');
            tag=parent;
            parent.document.getElementById("b").innerHTML=document.getElementById("d").innerHTML;
        }else{
            alert('不加载到父窗体');
            tag=window;
        }
           if(tag.CKEDITOR){
             var script=document.createElement('script');
             script.src='http://ckeditor.com/apps/ckeditor/3.6.1/ckeditor.js?1309164514';
             tag.document.getElementsByTagName('head')[0].appendChild(script);
            
            }
            setTimeout(function(){
                showEdit();
             },25);        function showEdit(){
                if(tag.CKEDITOR){
                    tag.CKEDITOR.replace('Content1_kk_kk_kk');
                }else{
                    setTimeout(showEdit , 25 );
                }
            }}
    </script>
    把这个脚本改下 逻辑是 判断下 加载环境中有CKEDITOR 就不加载CKEDITOR.js你的页面关系和结构有点不太流畅 
    我这个只是旁门左道 只能救救急
    正确做法是吧你的页面关系和结构适当调整下
      

  19.   

    if(!tag.CKEDITOR){
             var script=document.createElement('script');
             script.src='http://ckeditor.com/apps/ckeditor/3.6.1/ckeditor.js?1309164514';
             tag.document.getElementsByTagName('head')[0].appendChild(script);
            
            }
    不好意思少了个 !
      

  20.   

    [Quote=引用 31 楼 kk3k2005 的回复:]不懂了,这一段不论是插进去,还是替换之前那个,都好像没有效果啊.