Skip to main content
Inspiring
June 2, 2012
Answered

CS6 hyperlink problem

  • June 2, 2012
  • 13 replies
  • 70385 views

Hi everyone,

 

In Indesign CS6, I created a new URL hyperlink and pasted the following link into the field:

http://law.ato.gov.au/atolaw/view.htm?docid=AID/AID2004688/00001

But when I click OK and then look in the URL field in the hyperlinks panel, I see that Indesign has changed the link to the following:

http://law.ato.gov.au/atolaw/view.htm%3Fdocid%3DAID/AID2004688/00001

Notice how it's swapping out the question mark (?) after .htm with %3F.

It's also swapping out the equals sign (=) with %3D.

This breaks the URL and makes it no longer workable.

I tried reinstalling Indesign but the problem still remains.

I wondered if anyone knows why this is happening and whether there's a workaround?

Appreciate any help.

    This topic has been closed for replies.
    Correct answer Laubender

    @gwhPoster – That seems to be an encoding problem. Do you use a prerelease beta version of InDesign CS6?

     

    Background:
    It seems that every URL that is filled in in the Hyperlink palette is encoded with something like encodeURI() (a global ExtendScript function):

    string encodeURI (text: string)

    Encodes a string after RFC2396.

    Create an UTF-8 ASCII encoded version of this string. The string is converted into UTF-8. Every non-alphanumeric character is encoded as a percent escape character of the form %xx, where xx is the hex value of the character. After the conversion to UTF-8 encoding and escaping, it is guaranteed that the string does not contain characters codes greater than 127. The list of characters not to be encoded is -_.!~*'();/?:@&=+$,#. The method returns false on errors.

     

    To get it back to a working URL we could decode it by "decodeURI()":

     

    string decodeURI (uri: string)

    Decodes a string created with encodeURI().

     

    To correct that you could use the following script (JavaScript).

    (After running the script don't go to "Hyperlink options…" in the Hyperlink panel and hit "OK" since the URL is converted back and you have to run the script again to correct that!)

     

    //DecodeURI_AllHyperlinks_DestinationURL_Name.jsx
    //DESCRIPTION:Decodes all hyperlink destination URLs and names; can be undone in one go!
    //Uwe Laubender
    
    /**
    
    * @@@BUILDINFO@@@ DecodeURI_AllHyperlinks_DestinationURL_Name.jsx !Version! Mon Jun 04 2012 14:48:49 GMT+0200
    
    */
    
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    
    app.doScript
    (
    	_DecodeURI_AllHyperlinks_DestinationURL_Name , 
    	ScriptLanguage.JAVASCRIPT, 
    	[] , 
    	UndoModes.ENTIRE_SCRIPT, 
    	"Decode all hyperlink URLs and names"
    );
    
    
    function _DecodeURI_AllHyperlinks_DestinationURL_Name()
    {
    
    	var d = app.documents[0];
    	var allHyperlinks = d.hyperlinks;
    
    	for(var n=0;n<allHyperlinks.length;n++)
    	{
    
    		var newDestURL = decodeURI( allHyperlinks[n].destination.destinationURL );
    		var newDestName = decodeURI( allHyperlinks[n].destination.name );
    
    		allHyperlinks[n].destination.destinationURL = newDestURL;
    
    		try{
    		allHyperlinks[n].destination.name = newDestName;
    		}catch(e){};
    
    	};
    
    }; //END function "_DecodeURI_AllHyperlinks_DestinationURL_Name()"
    

     

    Hope that helps.

    Uwe

     

    IMPORTANT NOTE:

    The code above was damaged before. Why? This happened at the end of 2019 when this thread was moved over from the old InDesign forum to this new InDesign forum. A lot of script code from a lot of threads were affected back then. I corrected the code now.

     

    Regards,
    Uwe Laubender

    ( ACP )

    13 replies

    Known Participant
    July 6, 2012

    This does the same thing for me Just got CS6...so "advanced" it's got werid bugs that were never there before...grrrr!!! Very annoyed with Adobe right now. How do I report a bug?

    Community Expert
    July 6, 2012

    How do I report a bug?

    @Aussie_leah – go there:

    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

    But do not expect Adobe answering…

    Uwe

    Participant
    June 6, 2012

    Hi,

    I was struggling with the same problem but was able to make it work by opening the Hyperlinks panel and manually amending the characters in the URL field (i.e. delete "%3F", key in "?"). Seems to publish to PDF with no issues. Hope that helps!

    Community Expert
    June 6, 2012

    @skim-creative – try out my script. It will change all hyperlink URLs and hyperlink names. You can undo the action in one go if you like…

    Uwe

    Participant
    June 27, 2012

    Hi

    I tried your script. I.e I copied the text to a text editor and saved as a .jsx file and placed within the script folder. When I ran it it gave an error number 14, no matching closing brace found?

    Cheers Nigel

    LaubenderCommunity ExpertCorrect answer
    Community Expert
    June 4, 2012

    @gwhPoster – That seems to be an encoding problem. Do you use a prerelease beta version of InDesign CS6?

     

    Background:
    It seems that every URL that is filled in in the Hyperlink palette is encoded with something like encodeURI() (a global ExtendScript function):

    string encodeURI (text: string)

    Encodes a string after RFC2396.

    Create an UTF-8 ASCII encoded version of this string. The string is converted into UTF-8. Every non-alphanumeric character is encoded as a percent escape character of the form %xx, where xx is the hex value of the character. After the conversion to UTF-8 encoding and escaping, it is guaranteed that the string does not contain characters codes greater than 127. The list of characters not to be encoded is -_.!~*'();/?:@&=+$,#. The method returns false on errors.

     

    To get it back to a working URL we could decode it by "decodeURI()":

     

    string decodeURI (uri: string)

    Decodes a string created with encodeURI().

     

    To correct that you could use the following script (JavaScript).

    (After running the script don't go to "Hyperlink options…" in the Hyperlink panel and hit "OK" since the URL is converted back and you have to run the script again to correct that!)

     

    //DecodeURI_AllHyperlinks_DestinationURL_Name.jsx
    //DESCRIPTION:Decodes all hyperlink destination URLs and names; can be undone in one go!
    //Uwe Laubender
    
    /**
    
    * @@@BUILDINFO@@@ DecodeURI_AllHyperlinks_DestinationURL_Name.jsx !Version! Mon Jun 04 2012 14:48:49 GMT+0200
    
    */
    
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    
    app.doScript
    (
    	_DecodeURI_AllHyperlinks_DestinationURL_Name , 
    	ScriptLanguage.JAVASCRIPT, 
    	[] , 
    	UndoModes.ENTIRE_SCRIPT, 
    	"Decode all hyperlink URLs and names"
    );
    
    
    function _DecodeURI_AllHyperlinks_DestinationURL_Name()
    {
    
    	var d = app.documents[0];
    	var allHyperlinks = d.hyperlinks;
    
    	for(var n=0;n<allHyperlinks.length;n++)
    	{
    
    		var newDestURL = decodeURI( allHyperlinks[n].destination.destinationURL );
    		var newDestName = decodeURI( allHyperlinks[n].destination.name );
    
    		allHyperlinks[n].destination.destinationURL = newDestURL;
    
    		try{
    		allHyperlinks[n].destination.name = newDestName;
    		}catch(e){};
    
    	};
    
    }; //END function "_DecodeURI_AllHyperlinks_DestinationURL_Name()"
    

     

    Hope that helps.

    Uwe

     

    IMPORTANT NOTE:

    The code above was damaged before. Why? This happened at the end of 2019 when this thread was moved over from the old InDesign forum to this new InDesign forum. A lot of script code from a lot of threads were affected back then. I corrected the code now.

     

    Regards,
    Uwe Laubender

    ( ACP )

    JKA@4153Author
    Inspiring
    June 4, 2012

    Thanks for the reply,

    No it wasn't a pre-release - it's just CS6. I've contacted adobe and they were able to replicate the problem from their end but they haven't fixed the issue as yet. I may need to use your script if they don't provide a solution so thanks for posting it.

    Community Expert
    June 4, 2012

    @gwhPoster – use the script with care. I did a little testing, but one never knows where it might fail…

    Uwe