Wiki source code of ContentEditable

Version 17.1 by mflorea on 2010/07/06 18:27

Show last authors
1 {{velocity}}
2 $xwiki.ssx.use("ContentEditable")
3 {{/velocity}}
4
5 {{html clean="false"}}
6 <script type="text/javascript">
7 function onAction(hook){
8 var iframe = document.createElement('iframe');
9 iframe.style.border = '1px solid black';
10 iframe.addEventListener('load', function() {
11 iframe.contentWindow.document.body.innerHTML = '<p>before<span contentEditable="false" class="readOnly" onclick="this.className=\'readOnly readOnly-selected\'">text</span>after</p>';
12 //iframe.contentWindow.document.designMode = 'on';
13 iframe.contentWindow.document.body.contentEditable = true;
14 iframe.focus();
15 }, false);
16 hook.parentNode.insertBefore(iframe, hook);
17 }
18 </script>
19 <button onclick="onAction(this)">Action</button>
20 {{/html}}