Ein Hyperlink hat im Wesentlichen zwei Eigenschaften, eine Quelle und ein Ziel. Das Ziel in Ihrem Fall ist eine URL, die im Browser geöffnet werden soll. Die Quelle ist jedoch tatsächlich ein InDesign-Textobjekt. Ziele können mehrmals verwendet werden, aber nur einmal pro Objekt. Daher würde ich empfehlen, auf Textquellen durch das Objekt zuzugreifen, das es tatsächlich verwendet, d. H. Einen Hyperlink.
var main = function() {
\t var doc = app.properties.activeDocument,
\t hlks,hlk,
\t src,
\t txt;
\t
\t if (!doc) return;
\t
\t hlks = doc.hyperlinks;
\t
\t
\t if (!hlks.length) return;
\t
\t hlk = hlks[0];
\t src = hlk.source;
\t
\t if (!(src instanceof HyperlinkTextSource)) return;
\t txt = src.sourceText;
\t app.select (txt);
\t
\t txt.parentTextFrames.length && zoomObject (txt.parentTextFrames[0]);
\t
\t alert("here you are…");
}
function zoomObject(theObj) {
try {
var objBounds = theObj.geometricBounds;
} catch (e) {
throw "Object doesn't have bounds."
}
var ObjHeight = objBounds[2] - objBounds[0];
var ObjWidth = objBounds[3] - objBounds[1];
var myWindow = app.activeWindow;
var pageBounds = myWindow.activePage.bounds;
var PgeHeight = pageBounds[2] - pageBounds[0];
var PgeWidth = pageBounds[3] - pageBounds[1];
var hRatio = PgeHeight/ObjHeight;
var wRatio = PgeWidth/ObjWidth;
var zoomRatio = Math.min(hRatio, wRatio);
myWindow.zoom(ZoomOptions.fitPage);
myWindow.zoomPercentage = myWindow.zoomPercentage * zoomRatio;
}
main();
Dank Pro funktioniert das mich für – Leo