Copy link to clipboard
Copied
Hi friends,
I want to add an attribute to an all element tag "img", but I don't see how to do it programmatically. Is it possible? Also, is there a way to name an element tag dynamically? For example: screenshot
my added attribute for (data-profile-deliveryformat=“digital”)
Advance thanks,
Copy link to clipboard
Copied
Try this,
var root = app.activeDocument.xmlElements[0];
var imgTag = root.evaluateXPathExpression('//img');
for(var i=0; i<imgTag.length; i++)
{
imgTag.xmlAttributes.add("data-profile-deliveryformat", "digital");
}
Copy link to clipboard
Copied
Hi Sajeev,
First fall Thanks your quick replay,
I have run in the your code but some error is happen. plz find out this problem. what can i do sajeev.
Indesign Cs6
Advance thanks
Karthik S
Copy link to clipboard
Copied
Use the below line at the top of your script
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
Copy link to clipboard
Copied
Hi Sajeev,
I have used your code below:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var root = app.activeDocument.xmlElements[0];
var imgTag = root.evaluateXPathExpression('//img');
for(var i=0; i<imgTag.length; i++)
{
imgTag.xmlAttributes.add("data-profile-deliveryformat", "digital");
}
But this is not add the xml attributes ("data-profile-deliveryformat", "digital") sajeev, plz tell again what can i do?
Thanks
Karthik
Copy link to clipboard
Copied
Hi Sajeev,
I and using application = cs6