Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript tostring issue
    text
    copied!<p>I'm working on a WYSIWYG text editor and I'm working on the ability to switch between the WYSIWYG mode and BBcode mode. I'm having trouble getting it to display back in WYSIWYG mode after you make the switch.</p> <pre><code>function editormode() { var html; var bbcode = new Array(); var htmlcode = new Array(); htmlcode[0] = "&lt;b&gt;"; bbcode[0] = "[b]"; htmlcode[1] = "&lt;/b&gt;"; bbcode[1] = "[/b]"; htmlcode[2] = "&lt;i&gt;"; bbcode[2] = "[i]"; htmlcode[3] = "&lt;/i&gt;"; bbcode[3] = "[/i]"; htmlcode[4] = "&lt;u&gt;"; bbcode[4] = "[u]"; htmlcode[5] = "&lt;/u&gt;"; bbcode[5] = "[/u]"; htmlcode[6] = "&lt;strike&gt;"; bbcode[6] = "[strike]"; htmlcode[7] = "&lt;/strike&gt;"; bbcode[7] = "[/strike]"; htmlcode[8] = "&lt;sub&gt;"; bbcode[8] = "[sub]"; htmlcode[9] = "&lt;/sub&gt;"; bbcode[9] = "[/sub]"; htmlcode[10] = "&lt;sup&gt;"; bbcode[10] = "[sup]"; htmlcode[11] = "&lt;/sup&gt;"; bbcode[11] = "[/sup]"; if (editormode == "true") { htmltext = document.getElementById('editor').contentWindow.document.body.innerHTML; for(i = 0; i &lt; 12; i++){ searchtext = htmltext.search(htmlcode[i]); if(searchtext != -1) { htmltext = htmltext.replace(htmlcode[i], bbcode[i]); } } html = document.createTextNode(htmltext); document.getElementById('editor').contentWindow.document.body.innerHTML = ""; html = document.getElementById('editor').contentWindow.document.importNode(html,false); document.getElementById('editor').contentWindow.document.body.appendChild(html); editormode = "false"; } else { htmltext = document.getElementById('editor').contentWindow.document.body.innerHTML; for(i = 0; i &lt; 12; i++){ searchtext = htmltext.search(bbcode[i]); if(searchtext != -1) { htmltext = htmltext.replace(bbcode[i], htmlcode[i]); } } html = document.createTextNode(htmltext); document.getElementById('editor').contentWindow.document.body.innerHTML = ""; html = document.getElementById('editor').contentWindow.document.importNode(html,false); document.getElementById('editor').contentWindow.document.body.appendChild(html); editormode = "true"; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload