1 2 var log_elem = null;3 var last_part=null;4 var selection= null;5 6 function log (text){7 log_elem.innerHTML = text;8 }9 10 window.addEventListener('load', init, true);11 12 function init() {13 selection = window.getSelection();14 15 log_elem = document.getElementById('log');16 last_part = document.getElementById('p1');17 18 document.getElementById('p1').editable = true;19 document.getElementById('p2').editable = true;20 document.getElementById('p3').editable = true;21 document.getElementById('p4').editable = true;22 23 24 document.getElementById('doc').addEventListener('keyup',click_handler, true);25 }26 27 28 29 function click_handler(event) {30 31 if (event.keyCode>36 && event.keyCode<41) {32 if (selection.anchorNode.parentNode.editable == true) {33 last_editable = selection.anchorNode.parentNode;34 log(last_editable.innerHTML);35 }36 } else {37 if (selection.anchorNode.parentNode.editable ==false) {38 selection.anchorNode = last_editable;39 }40 }41 }
Este ShareCode tiene versiones:
- comentarios aaaa comentario... (05/07/2011)
- comentarios aaaa comentario... (24/04/2013)
- comentarios aaaa comentario... (24/04/2013)
Enlace
El enlace para compartir es: