locked
Web page editor not accepting OnClick attribute in button tag RRS feed

  • Question

  • We are testing Office 365 for our company webpage.  We are trying to use Office web page designer, and edit the source for additional functions when needed.  we created a simple test script for a button and the onclick event as follow:

     <div>
       <p>
          <button onclick="showdetail();">hideshow</button></p>
       <p id="detail" style="display:none;">message is showing </p>
    </div>
     <script>
    function showdetail(){
           document.getElementById("detail").style.display="block";
    }
    </script>

    the script was added using script editor and we then add the onclick event by editing the html source. on save, CEWP will just wipe out the onclick attribute and leave the button without event handler.  Is it a bug in CEWP? the same behavior was observed when we tried the same event on link tag.

    Wednesday, May 1, 2013 5:31 AM

Answers

  • Thanks.  the problem was resolved after reviewing the links you provided.  instead of using /embed code, the script and html codes with the function are put in a text file with .txt extension.  the file is included in the webpage as webpart to avoid content being remove by the editor.
    • Marked as answer by hermes88 Saturday, May 4, 2013 1:54 AM
    Saturday, May 4, 2013 1:53 AM

All replies