3

この属性について知ったばかりで、そのcontenteditable実用的な使い方を考えていました。

ページの更新が速いのは素晴らしいと思いますが、次のような懸念事項があります。

  • セキュリティ: 誰にもページを更新されたくないのは明らかなので、コンテンツの編集を許可することはかなり厳密に制御する必要があります
  • ログイン後にページのコンテンツを編集可能にします。これには、ページ全体のマークアップを変更する必要があるのではないでしょうか? それ自体は問題ではありませんが、私が想像するかなり大きな仕事です
  • 新しいコンテンツを保存しています。理論的には、これは ajax と json を使用して、データベースのフィールドに新しいページ マークアップを保存することで実行できます。また、「これで変更が完了しました。これで保存できます」ということを実際にどのようにウェブサイトに確認しますか。

ページのコンテンツを表示する場所ですばやく編集するというこのアイデアが気に入っています。私は自分のウェブサイトにそのようなものを実装することに非常に興奮していますが、それを試みる前に少しのガイダンスを使用できます.

上記の問題と、関連性があるとは思わなかった問題に誰かが対処できますか?

御時間ありがとうございます!

4

1 に答える 1

3
  • Security Yes, you don't want just anyone to update your page, but that's not anything to do with contenteditable itself. People can change the content of any page on the internet right now using the browser's development tools but, other than faking funny screenshots, it's not much use to them if the server doesn't accept updates. The more important issue here is protecting against things like cross-site scripting attacks by making sure the content the user adds to the page is 'safe' (this, for example, is why blogs typically disallow most HTML tags in comments).
  • Making content editable after login Simply add the contenteditable attribute in the server side logic after the user has logged in. Alternatively, add it with JavaScript when the user clicks an 'Edit' button. I wouldn't expect it to change the whole page's markup because for this approach to be sensible the pages would already be getting generated at the server side anyway from a template being filled with content stored in a database. If you're talking about making a static site editable then, yes, you'd have a lot of work to do, but you'd have that work to do however you planned on letting people edit the pages.
  • Saving the new content Yes, do it with Ajax. JSON is not really necessary, it's the HTML content you want to send back, right? Send it back as HTML, just bear in mind the above comment about cross-site scripting and do security checks on the server side (never trust user input). How you confirm the user is done editing is up to you, in the same way that you're going to have to add programming logic to send the changes back with Ajax and process those changes on the server, you're going to have to add logic which shows editing tools (buttons for bold, italic etc.) when necessary - add a button to perform the update at the same time.
于 2012-11-13T09:01:23.843 に答える