2014-10-20 21 views
0

在我的asp.net应用程序中使用<code>HTML Editor</code>(ajax工具包)在页面加载时设置的Ajax工具箱HTML编辑器的值

问题:我的问题是,当我想分配或设置在页面加载价值HTMLEditor,但它不工作(下面的代码)。

但使用相同的代码,我可以检索或成功获取值。

的JavaScript:

<script type="text/javascript"> 
    $(document).ready(function() 
    { 
     document.getElementById("ContentPlaceHolder1_Editor1_ctl02").contentWindow.innerHTML = "Some value from db"; 
     // not working :(
    }); 

    function getValue() 
    { 
     var content = document.getElementById("ContentPlaceHolder1_Editor1_ctl02_ctl00").contentWindow.document.body.innerHTML 
     // this working perfect. 
    } 
    function copyText() 
    { 
     document.getElementById("ContentPlaceHolder1_Editor1_ctl02").contentWindow.innerHTML = "Some Value from another div"; 
     // working perfect. 
    } 
    </script> 

我的问题是我不能够在文件准备功能,以设置HTML Editor值。但同样我可以复制另一个div的内容,我可以在HTML Editor中设置该文本。

请给我建议,我怎么能在HTML Editor设定的值document.ready事件中

感谢,

回答

0

这可能是因为HTML编辑器中的计时问题,在加载时,确实有一些JavaScript来跑。你可以试试

window.setTimeout(document.getElementById("ContentPlaceHolder1_Editor1_ctl02").contentWindow.innerHTML = "Some value from db",0); 

把你的代码放在堆栈的末尾。

相关问题