We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36551
    • 416 Posts
    Can someone provide step by step instructions for enabling the use of onClick="LogClick(this); in a link in TinyMCE?

    I've searched through the forum and general google searches and have found conflicting, incomplete or version specific steps. In some cases editing config files was called for, but I'm not sure if an update would overwrite this approach.

    It would be cool if it could be added to RTFM next to the other TinyMCE instructions.

    Modx 2.3.5-pl
    TinyMCE 4.3.3-pl

    Thanks!
      • 3749
      • 24,544 Posts
      I don't have an answer for you, but your line is missing its closing quotation mark:

      onClick="LogClick(this);"


      Probably just a typo on your part, but I thought I'd mention it in case it's not.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36551
        • 416 Posts
        Right. Just an example. Would be nice to know for other elements and attributes that TinyMCE strips out.
          • 3749
          • 24,544 Posts
          I don't use TinyMCE for anything, but there's probably something here.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 42562
            • 1,145 Posts
            See https://forums.modx.com/thread/97993/responsive-images-in-modx-tinymce#dis-post-529940
            What you are looking for is:
            valid_elements: 'a[*],...' //allow all attributes of link

            or
            valid_elements: 'a[href|class|id|onClick],...' //limited allowance

            The Extra you are using is outdated, you will most probably not find this option in your system settings
              TinymceWrapper: Complete back/frontend content solution.
              Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
              5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
              • 36551
              • 416 Posts
              Yes, I've found references to this in several places, but where to put it?

              There is no setting for valid_elements only invalid_elements on this version of TinyMCE in system settings.

              Tinymcerte-1.1.0-pl doesn't have either setting.

              So where does one put this code?
                • 42562
                • 1,145 Posts
                https://forums.modx.com/thread/97987/issue-with-absolute-paths#dis-post-529936
                If you insist on using Tinymcerte-1.1.0 here is a simple solution:
                Alter yourSite/assets/components/tinymcerte/js/mgr/tinymcerte.js

                Wait for next release TinymceWrapper (this week), it has support for MODx native browser, RFM, elFinder and Roxy.
                Only RFM might need extra permission for commercial use.

                Time to ditch any extra that limits you unnecessarily.
                  TinymceWrapper: Complete back/frontend content solution.
                  Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                  5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                  • 3749
                  • 24,544 Posts
                  elFinder will be great. What's next? elRTE, Aloha, CkEditor ... wink
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 50887
                    • 6 Posts
                    Me to wants TinyMCErte NOT removing onclick attribute.
                    Alter yourSite/assets/components/tinymcerte/js/mgr/tinymcerte.js
                    Don't have a clue what to edit there..
                    May we conclude there is no way to change this behavior? Somebody from TinyMCE mentioned it is a possible XML injection risk, but let it please be to us to take that risk..
                      • 42562
                      • 1,145 Posts
                      Quote from: harryk at Aug 13, 2015, 03:05 PM
                      Me to wants TinyMCErte NOT removing onclick attribute.
                      ... May we conclude there is no way to change this behavior? Somebody from TinyMCE mentioned it is a possible XML injection risk, but let it please be to us to take that risk..
                      Risk or no risk, TinyMCE allows you to do anything you want with element attributes.
                      http://www.tinymce.com/wiki.php/Configuration:valid_elements

                      This works perfectly for me

                      Open yourSite/assets/components/tinymcerte/js/mgr/tinymcerte.js
                      Find
                      Ext.extend(TinyMCERTE.Tiny,Ext.Component,{
                          cfg: {
                              selector: '#ta'
                              ,document_base_url: MODx.config.base_url
                              ,file_browser_callback_types: 'file image media'
                          }
                      

                      alter to this
                      Ext.extend(TinyMCERTE.Tiny,Ext.Component,{
                          cfg: {
                              selector: '#ta'
                              ,valid_elements: 'a[*]' //add this line + other elements
                              ,document_base_url: MODx.config.base_url
                              ,file_browser_callback_types: 'file image media'
                          }
                      

                      Note
                      selector: '#ta' targets the content area.
                      Add this functionality to anywhere you see selector: ...
                      Be careful of the commas.
                      An upgrade to the Extra will wipe these your changes, so back up.
                        TinymceWrapper: Complete back/frontend content solution.
                        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.