开发者

HTML5 ContentEditable

开发者 https://www.devze.com 2023-02-15 17:30 出处:网络
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.

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.

  • 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.

  • How would I save content that is changed in HTML5 ContentEditable?


How would I save content that is changed in HTML5 ContentEditable?

Assuming that you have a div that's contentEditable, like:

<div id="content" contentEditable="true">here goes your contenteditable content</div>

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>

You'd then receive a post request with you save.php script. You can access the posted data using $_POST['content'];

0

精彩评论

暂无评论...
验证码 换一张
取 消