HTML5 ContentEditable [英] HTML5 ContentEditable
问题描述
我有一些关于HTML5 ContentEditable和PHP的问题,如果你能提供我想要做的事情的例子,我会很高兴我能得到一个想法。
I have a few questions regarding HTML5 ContentEditable and PHP, I would be very happy if you could provide me with examples of what I am trying to do so I can get an idea.
-
我有一个我想编辑的网站,但只有登录Admin - 我可以做登录方面但我不确定如何编码HTML5 ContentEditable进入它,以便在Admin未登录时不加载。
I have a website that I would like to edit but only if "Admin"is logged in - I can do the login side of things but I am unsure how to code the HTML5 ContentEditable into it so that it does not load when "Admin" is not logged in.
如何保存HTML5 ContentEditable中更改的内容?
How would I save content that is changed in HTML5 ContentEditable?
推荐答案
我如何保存那些内容是否在HTML5中更改了ContentEditable?
How would I save content that is changed in HTML5 ContentEditable?
假设您的div为 contentEditable
,例如:
Assuming that you have a div that's contentEditable
, like:
<div id="content" contentEditable="true">here goes your contenteditable content</div>
完成编辑后(比如当你点击保存按钮时)你必须做这样的事情(用 jQuery
):
After you've finished editing (like when you're clicking the save-button) you have to do something like this (with jQuery
):
<script type="text/javascript">
$.post('save.php', {
content : $('#content').html()
}
</script>
然后您将收到一封包含save.php脚本的帖子请求。您可以使用<$ c访问发布的数据$ c> $ _ POST ['content'];
You'd then receive a post request with you save.php script. You can access the posted data using $_POST['content'];
这篇关于HTML5 ContentEditable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!