1 Reply Latest reply on Oct 29, 2009 2:53 AM by [Jongware]

    [CS3][JS]Add Tag to text

    kumar1981 Level 1

      hi,

       

         I need to apply tag to selected text in a layout.We can do it manually by selecting text in a layout and then choosing tag from 'Tags' window.The same thing needs to be done using Javascript.I have used the following code,but it adds tag to entire paragraph,not for selected text.The paragraph is already tagged. I need to add tag(sub tag) for selected text which is already tagged.

       

      app.selection[0].associatedXMLElements[0].markupTag=myDoc.xmlTags.item("subtitle");

       

       

      Please suggest me.

       

       

      Regards

      kumar

        • 1. Re: [CS3][JS]Add Tag to text
          [Jongware] Most Valuable Participant

          This tags any selected text:

           

          app.activeDocument.xmlElements.item(0).xmlElements.add ("subtitle", app.selection[0]);

          and adds this tag to the one containing the selection (despite adding it to the 'root' of the document). It seems not to care whether the selection already is tagged -- it always adds another one.