Welcome to the in5 Answer Exchange! This a place to get answers about in5 (InDesign to HTML5) and make requests.
0 votes

Dear in5 team,

By upgrading to in5-3.8.10 have noticed, that HyperLinks defined from Indesign throw an error at iOS Safari.

Example of link, exported from InDesign via IN5.

<a href="javascript:myFunction()">

        <div id="item783" alt="" class="pageItem ">&nbsp;</div>

      </a>

I suppose, you need to ask IN5 developers, to adjust function definition from "assets/js/in5.config.js" to strip "javascript:" prior call strict function like:

function strfunc(str,cthis){

if(!str || !str.length){ return; }

if(cthis){ str = str.replace(/this\)/g, '$(\'[data-uid="'+getUID(cthis)+'"]\')[0])'); }

str.replace(/;$/,'').split(';').forEach(function(s){

    s = s.replace("javascript:", "");

   try{ return Function('"use strict";return ('+s+')')(); }

   catch(err){console.log('strfunc error running: '+s+'\r>>>'+err)}

   }) 

}

 

in bugs by (680 points)
  

1 Answer

0 votes
Thank you for sending the code over. We will have a developer take a look.
by (4.0k points)

Here's the information I got from our developer about what sounds like the same issue with hyperlinks:

They said that there's in issue in the openLink function in in5.config.js. In other browsers the JavaScript action from the link is handled automatically, however in iOS, the openLink function is called to "deal w buggy ios propagation". The openLink function then passes the js action to strfunc, however the javascript: part of the string is not removed which throws an error in strfunc.
Here's how the function looks in 3.8.10:
function openLink($a,e){
    var href=$a.attr('href'), w;
    if(href.indexOf('javascript:')===0){strfunc(href,$a[0]); w=!0;}
    else { w = window.open(href,$a.attr('target')||'_blank'); }
    if(e && w){ e.preventDefault(); }
}
You can modify the function above to remove the javascript: part of the string as follows:
function openLink($a,e){
    var href=$a.attr('href'), w;
    if(href.indexOf('javascript:')===0){strfunc(href.substring("javascript:".length),$a[0]); w=!0;} <--- MODIFIED LINE
    else { w = window.open(href,$a.attr('target')||'_blank'); }
    if(e && w){ e.preventDefault(); }
}
To modify the code yourself, you can do the following:
  1. Open the in5.config.js file in a text editor such as TextEdit (macOS) or Notepad (Windows) or in an IDE such as Dreamweaver which is available if you have the full Adobe Creative Cloud subscription.
  2. Search for the function: 
    function openLink($a,e){
  3. Copy the modified code that includes the yellow highlighted line that was added.
  4. Replace the code in the in5.config.js file.
  5. Save the changes.
The fix will be applied in5 version 3.8.11, but we currently don't have an ETA on when that will be released.