We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17895
    • 209 Posts
    Hi all,
    I’m writing some articles about AJAX, JavaScript, C++, and so on. I have a div class called code that shows and displays everything in a pretty box, fixed font and so on.
    The problem is that when I write the code in the TinyMCE, copy and pasting using the "edit HTML" stuff, in this way:

    <div class="code">
    // Hi all this is code
    function myFunction(somethingHere)
    {
      for (var i = 0; i < 10; i++) {
        document.write(i + " ");
      }
    }
    </div>
    


    The problem is that TinyMCE decide to strip all whitespaces and the result is this:

    <div class="code">
    // Hi all this is code
    function myFunction(somethingHere)
    {
    for (var i = 0; i < 10; i++) {
    document.write(i + " ");
    }
    }
    </div>
    


    (and... I’m not mention here... but there’s a problem with the <, that cannot appear in the code!)
      Daniele "MadMage" Calisi
      • 7923
      • 4,213 Posts


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."