0 Replies Latest reply on May 28, 2013 3:33 PM by Symbolic3

    Modifying text frame contents with javascript breaks cross reference links

    Symbolic3

      When I modify the contents of a text frame manually in a document (as in backspace or type additional characters), and the text frame is a cross reference destination, I am given the option to update the cross refence link.  However, if I modify the string in the same manner using javascript and any of the string methods such as string.concat or string.replace, it will break the cross reference and there is no option to update the cross reference link.  Why does the javascript version break my links without the option to update?

       

      Example: I have a text frame on the active page with the contents "Test link"; it is a cross reference destination, and thus has the ":" hidden character at the beginning of it which is counted as a character in the string.  If write the following to replace the word "link" with "new text" using the following code, the cross reference is broken and I do not get an option to update the link.

      ----

      var myDoc = app.activeDocument;

      var currentPage = app.activeWindow.activePage;

       

      var textLink = currentPage.allPageItems;

      var replaceThis = textLink[0].contents.slice(6);

      textLink[0].contents = textLink[0].contents.replace(replaceThis, "new text");

       

      ----

       

      If I were to manually delete the word "link" in the document and type in "new text," I have the option to update the link. Can someone help explain how to maintain the cross reference link, or at least the option to update cross reference links when I update the text using javascript?