使用默认内容初始化tinyMCE [英] initialize tinyMCE with default content

查看:2172
本文介绍了使用默认内容初始化tinyMCE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 tinyMCE 的快速提问。我有一个textarea, id =mainbuffer,函数 tinyMCE.get(id).setContent(data)

I have a quick question about tinyMCE. I have a textarea, with id="mainbuffer", and the function tinyMCE.get(id).setContent(data).

只有在链接中调用 onclick =function()时才有效加载页面时工作。在我的例子中,它是: tinyMCE.get('mainbuffer')。setContent(localStorage.getItem('mainbuffer'));

ONLY works when it is called onclick="function()" from a link and does not work when I load the page. In my case, it is: tinyMCE.get('mainbuffer').setContent( localStorage.getItem('mainbuffer') );

我试过 tinyMCE.execCommand(),但这也不起作用。

I've tried tinyMCE.execCommand(), but that doesn't work either.

我希望JavaScript函数使用localStorage中存储的数据初始化textarea,我已经检查过,它正常工作。有什么建议吗?

I want the JavaScript function to initialize the textarea with data stored in localStorage, which I have checked, is working fine. Any suggestions?

推荐答案

如果您想在页面加载时放置脚本,请确保将代码放入document.ready或之后TinyMCE和你的元素已被加载。

If you want to put script on page load, make sure you put your code in document.ready or after TinyMCE and your element has been loaded.

document.ready=function(){
   //debug document.getElementById('mainbuffer') return not undefined?
   tinyMCE.get('mainbuffer').setContent( localStorage.getItem('mainbuffer') );
}

这篇关于使用默认内容初始化tinyMCE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆