Skip to main content
Participant
June 24, 2008
Question

Link position.

  • June 24, 2008
  • 7 replies
  • 704 views
Hi!
I need to delete all links from document except links which lead to the images on the master pages.
So, how can i understand it?
As I know,
parent of the link is image
parent of the image is recangle
(this information from this forum +) )
and how i think
parent of rectangle is page.
so how to check up the page?
This topic has been closed for replies.

7 replies

Participant
June 24, 2008
Oh! Big big tnx!
Very nice code!
and very instructively.
Tnx again!
Kasyan Servetsky
Legend
June 24, 2008
Hi Vadim,

I wrote this function to find where a link was placed: master page, pasteboard of master page, page, pasteboard or as an inline object. It works with links in groups and nested groups.

function whereIsTheLink(theLink){

while (theLink.constructor.name != 'Application') {
theLink = theLink.parent;
myHierarchy += theLink.constructor.name + '|';
}
if (myHierarchy.lastIndexOf('|Character|Story|Document|Application|') != -1)
{
return 'inline object';
}
else if (myHierarchy.lastIndexOf('|Page|MasterSpread|Document|Application|') != -1)
{
return 'master page';
}
else if (myHierarchy.lastIndexOf('|MasterSpread|Document|Application|') != -1)
{
return 'pasteboard of master page';
}
else if (myHierarchy.lastIndexOf('|Page|Spread|Document|Application|') != -1)
{
return 'page';
}
else if (myHierarchy.lastIndexOf('|Spread|Document|Application|') != -1)
{
return 'pasteboard';
}
}


Kasyan
Participant
June 24, 2008
Tnx, again+) I did it already.
Peter Kahrel
Community Expert
Community Expert
June 24, 2008
Let's say that constructor.name tells you the name of an object. E.g. "guides".constructor.name returns "String". If you want more detailed info you can consult a Javascript guide.

Peter
Participant
June 24, 2008
I tested your code.
Tnx, it is correct!
Participant
June 24, 2008
Tnx,
can you discribe in detail what is the property constructor?
Peter Kahrel
Community Expert
Community Expert
June 24, 2008
See what you get when you go back another generation:

if (myImage.parent.parent.parent.constructor.name != 'MasterSpread)
//delete image

Peter