We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1371
    • 9 Posts
    I am trying to add a simple javascript into the text editor (not the rich text editor but the clean one). When viewing my rendered page I found out that ModX converted all my
    \'
    (slant followed by apostraphe) tags to
    '
    (an apostraphe without the slant) this made the javascript unusable. is there any way to make ModX show the missing slant?

    example:
    this is what i’m trying to enter:
    <a target="newwin" href="http://www.faa.gov/library/manuals/aircraft/airplane_handbook/" onmouseover="this.T_WIDTH=140;return escape('<img src=\'afhCover.jpg\' width=\'130\'>')">Airplane Flying Handbook</a>
    


    and this is what i get on the rendered page:
    <a target="newwin" href="http://www.faa.gov/library/manuals/aircraft/airplane_handbook/" onmouseover="this.T_WIDTH=140;return escape('<img src='afhCover.jpg' width='130'>')">Airplane Flying Handbook</a>
    


    Thank you and great job on making ModX!
      • 22303 MODX Staff
      • 10,725 Posts
      MODx version? Any additional platform/environment information might be helpful as well.
        • 24414
        • 45 Posts
        If you add all your event-driven code to an external .js file MODx will never have to parse your JavaScript at all.
          • 1371
          • 9 Posts
          I am running on an apache server with ModX version 0.9.2.1.
          There are no problems with any of the ModX features. Just trying to find a way to get over this parsing problem.

          If its not possible i will use an external .js

          Thank you
            • 22303 MODX Staff
            • 10,725 Posts
            Why not use double-quotes for that stuff you are escaping? That would be the valid approach anyway, since single quotes around HTML attribute values is not valid.

            <a target="newwin" href="http://www.faa.gov/library/manuals/aircraft/airplane_handbook/" onmouseover="this.T_WIDTH=140;return '<img src="afhCover.jpg" width="130">'">Airplane Flying Handbook</a>


            Wouldn’t that work? I guess not, nevermind...

            Yeah, I think calling a js function there would be the best choice, but I would like to know why that is happening; I remember running into this problem when using MODx to generate JSON responses.