Search Results

Search found 3 results on 1 pages for 'chanthou'.

Page 1/1 | 1 

  • Rich Text Editor in javascript

    - by chanthou
    iframe .text-bold{ border:1px solid orange; background-color:#ccc; width:16px; height:16px; font-weight:bold; cursor:pointer; } .active{ border-color:#9DAECD #E8F1FF #E8F1FF #9DAECD; background-color:yellow; } function init( ) { iframe = document.createElement("iframe"); document.body.appendChild(iframe); iframe.onload = setIframeEditable; isBold=false; div=document.getElementById("bold"); } var setIframeEditable = function(){ iframe.contentDocument.designMode='on'; iframe.focus(); } function makeBold(){ if(!isBold){ //console.log(iframe.contentDocument.execCommand("bold", false, null)); iframe.contentDocument.execCommand("bold", false, null); div.className += " active"; isBold=true; iframe.focus(); }else{ //console.log(iframe.contentDocument.execCommand("bold", true, null)); iframe.contentDocument.execCommand("bold", false, null); div.className ="text-bold"; isBold=false iframe.focus(); } } </script> </head> <body onload="init()"> <div id="bold" class="text-bold" onclick="makeBold()">B</div> </body>

    Read the article

  • How do I find out the DOM node when select text in a browser’s editable content window using Javascr

    - by chanthou
    I want to get parentElement when I select some text in iframe. iframe = document.getElementById("iframe"); function getParentElement(){ var sel=iframe.contentDocument.getselection(); return sel.parentElement() } getParentElement(); when I run this code it show Error:" TypeError: iframe.contentDocument.getSelection().parentElement is not a function { message="iframe.contentDocument....ement is not a function", more...}" Please give me a help!

    Read the article

1