-
1. Re: Why does indesign escape my hyperlinks?
Salah Fadlabi Aug 5, 2013 12:03 AM (in response to NViereckel) -
2. Re: Why does indesign escape my hyperlinks?
Peter Kahrel Aug 5, 2013 1:08 AM (in response to NViereckel)This is a reported bug in InDesign. It happens when you create a URL hyperlink using New Hyperlink -- when you create a link using New Hyperlink from URL it doesn't happen. To fix URLs in a document, you can use this script:
var URLs = app.documents[0].hyperlinkURLDestinations.everyItem().getElements(); for (var i = URLs.length-1; i > -1; i--){ URLs[i].name = decodeURI(URLs[i].name) URLs[i].destinationURL = decodeURI(URLs[i].name); }Peter
-
3. Re: Why does indesign escape my hyperlinks?
vectorbabe Aug 5, 2013 4:00 AM (in response to NViereckel)Don't create them using the New Hyperlink Destination command in the panel menu.
Try pasting the link in the little field at the top of the panel.
--
Sandee Cohen
Computer Graphics Trainer
-
4. Re: Why does indesign escape my hyperlinks?
Electroscribe1109 Aug 5, 2013 8:52 AM (in response to Peter Kahrel)Attempted to create a script but got this error:
var URLs = app.documents[0].hyperlinkURLDestinations.everyItem().getElements();
original post:
var URLs = app.documents[0].hyperlinkURLDestinations.everyItem().getElements();
for (var i = URLs.length-1; i > -1; i--){
URLs[i].name = decodeURI(URLs[i].name)
URLs[i].destinationURL = decodeURI(URLs[i].name);
-
5. Re: Why does indesign escape my hyperlinks?
Laubender Aug 5, 2013 9:28 AM (in response to Peter Kahrel)@Peter – I wonder why you are using the value for the "name"-property of the hyperlinkURLDestination for two different things:
1. The "name"
2. The "destinationURL"As we can see in the screenshot provided by Salah in answer #1, one can change the name and leave the URL intact (whatever the reason to do so might be).
So I think would be better to use the decodeURI() method on both, the "name" and the "URL" like that:
var URLs = app.documents[0].hyperlinkURLDestinations.everyItem().getElements(); for (var i = URLs.length-1; i > -1; i--){ URLs[i].name = decodeURI(URLs[i].name); URLs[i].destinationURL = decodeURI(URLs[i].destinationURL); };Uwe
-
6. Re: Why does indesign escape my hyperlinks?
Peter Kahrel Aug 5, 2013 3:13 PM (in response to Laubender)Uwe,
I never thought about it like that. You're probably right, but that script works fine for me as it is.
decodeURI(URLs[i].destinationURL)probably returns a string, so it may well be the case that we're actually doing the same thing. Will try your version.Peter
-
7. Re: Why does indesign escape my hyperlinks?
Laubender Aug 5, 2013 11:42 PM (in response to Peter Kahrel)@Peter – If one is creating a fresh hyperlink, the values of "name" and "destinationURL" of hyperlinkURLDestination are the same. Both values are of type "string" (according to Jongware's DOM documentation).
Your script will work in every case the user will not change the "name" property in the "Hyperlink Destination Options". Why one should do that, I don't know. But in case, it's better to decode "destinationURL" independently from "name".
Uwe
//EDIT: "of hyperlinkURLDestination" added.
Message was edited by: Laubender



