Class Link
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Vínculo
Es un vínculo de hipertexto.
Documentación detallada
getLinkType()
Devuelve el LinkType
.
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null) {
Logger.log(`Shape has a link of type: ${link.getLinkType()}`);
}
Volver
LinkType
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getLinkedSlide()
Muestra el Slide
vinculado para los tipos de vínculos que no son de URL, si existe. Muestra null
si la diapositiva no existe en la presentación o si LinkType
es LinkType.URL
.
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() !== SlidesApp.LinkType.URL) {
Logger.log(`Shape has link to slide: ${link.getLinkedSlide()}`);
}
Volver
Slide
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getSlideId()
Muestra el ID del Slide
o null
vinculado si LinkType
no es LinkType.SLIDE_ID
.
Ten en cuenta que es posible que no exista la diapositiva con el ID que se muestra.
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_ID) {
Logger.log(`Shape has link to slide with ID: ${link.getSlideId()}`);
}
Volver
String
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getSlideIndex()
Muestra el índice basado en cero del Slide
o null
vinculado si LinkType
no es LinkType.SLIDE_INDEX
.
Ten en cuenta que es posible que la diapositiva en el índice que se muestra no exista.
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_INDEX) {
Logger.log(`Shape has link to slide with index: ${link.getSlideIndex()}`);
}
Volver
Integer
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getSlidePosition()
Muestra el SlidePosition
del Slide
o null
vinculado si el LinkType
no es LinkType.SLIDE_POSITION
.
Ten en cuenta que es posible que no exista la diapositiva con la posición relativa que se muestra.
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_POSITION) {
Logger.log(
`Shape has link to slide with relative position: ${
link.getSlidePosition()}`,
);
}
Volver
SlidePosition
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getUrl()
Muestra la URL de la página web externa o null
si LinkType
no es LinkType.URL
.
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.URL) {
Logger.log(`Shape has link to URL: ${link.getUrl()}`);
}
Volver
String
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-26 (UTC)
[null,null,["Última actualización: 2025-07-26 (UTC)"],[[["\u003cp\u003eA \u003ccode\u003eLink\u003c/code\u003e object represents a hypertext link associated with a shape in Google Slides.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to determine the link type, retrieve linked slide information (if applicable), and access the URL for external web page links.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetLinkType()\u003c/code\u003e method identifies the type of link, such as URL, slide ID, or slide index.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003egetLinkedSlide()\u003c/code\u003e, \u003ccode\u003egetSlideId()\u003c/code\u003e, \u003ccode\u003egetSlideIndex()\u003c/code\u003e, and \u003ccode\u003egetSlidePosition()\u003c/code\u003e retrieve information about linked slides based on the link type.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetUrl()\u003c/code\u003e method returns the URL if the link type is \u003ccode\u003eURL\u003c/code\u003e, otherwise, it returns \u003ccode\u003enull\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class Link\n\nLink\n\nA hypertext link. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------|---------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [getLinkType()](#getLinkType()) | [LinkType](/apps-script/reference/slides/link-type) | Returns the [LinkType](/apps-script/reference/slides/link-type). |\n| [getLinkedSlide()](#getLinkedSlide()) | [Slide](/apps-script/reference/slides/slide) | Returns the linked [Slide](/apps-script/reference/slides/slide) for non-URL links types, if it exists. |\n| [getSlideId()](#getSlideId()) | `String` | Returns the ID of the linked [Slide](/apps-script/reference/slides/slide) or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not [LinkType.SLIDE_ID](/apps-script/reference/slides/link-type#SLIDE_ID). |\n| [getSlideIndex()](#getSlideIndex()) | `Integer` | Returns the zero-based index of the linked [Slide](/apps-script/reference/slides/slide) or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not [LinkType.SLIDE_INDEX](/apps-script/reference/slides/link-type#SLIDE_INDEX). |\n| [getSlidePosition()](#getSlidePosition()) | [SlidePosition](/apps-script/reference/slides/slide-position) | Returns the [SlidePosition](/apps-script/reference/slides/slide-position) of the linked [Slide](/apps-script/reference/slides/slide) or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not [LinkType.SLIDE_POSITION](/apps-script/reference/slides/link-type#SLIDE_POSITION). |\n| [getUrl()](#getUrl()) | `String` | Returns the URL to the external web page or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not [LinkType.URL](/apps-script/reference/slides/link-type#URL). |\n\nDetailed documentation\n----------------------\n\n### `get``Link``Type()`\n\nReturns the [LinkType](/apps-script/reference/slides/link-type).\n\n```javascript\nconst shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];\nconst link = shape.getLink();\nif (link != null) {\n Logger.log(`Shape has a link of type: ${link.getLinkType()}`);\n}\n```\n\n#### Return\n\n\n[LinkType](/apps-script/reference/slides/link-type)\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Linked``Slide()`\n\nReturns the linked [Slide](/apps-script/reference/slides/slide) for non-URL links types, if it exists. Returns `null` if\nthe slide doesn't exist in the presentation, or if the [LinkType](/apps-script/reference/slides/link-type) is [LinkType.URL](/apps-script/reference/slides/link-type#URL).\n\n```javascript\nconst shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];\nconst link = shape.getLink();\nif (link != null && link.getLinkType() !== SlidesApp.LinkType.URL) {\n Logger.log(`Shape has link to slide: ${link.getLinkedSlide()}`);\n}\n```\n\n#### Return\n\n\n[Slide](/apps-script/reference/slides/slide)\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Slide``Id()`\n\nReturns the ID of the linked [Slide](/apps-script/reference/slides/slide) or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not\n[LinkType.SLIDE_ID](/apps-script/reference/slides/link-type#SLIDE_ID).\n\nNote that the slide with the returned ID might not exist.\n\n```javascript\nconst shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];\nconst link = shape.getLink();\nif (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_ID) {\n Logger.log(`Shape has link to slide with ID: ${link.getSlideId()}`);\n}\n```\n\n#### Return\n\n\n`String`\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Slide``Index()`\n\nReturns the zero-based index of the linked [Slide](/apps-script/reference/slides/slide) or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not [LinkType.SLIDE_INDEX](/apps-script/reference/slides/link-type#SLIDE_INDEX).\n\nNote that the slide at the returned index might not exist.\n\n```javascript\nconst shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];\nconst link = shape.getLink();\nif (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_INDEX) {\n Logger.log(`Shape has link to slide with index: ${link.getSlideIndex()}`);\n}\n```\n\n#### Return\n\n\n`Integer`\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Slide``Position()`\n\nReturns the [SlidePosition](/apps-script/reference/slides/slide-position) of the linked [Slide](/apps-script/reference/slides/slide) or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not [LinkType.SLIDE_POSITION](/apps-script/reference/slides/link-type#SLIDE_POSITION).\n\nNote that the slide with the returned relative position might not exist.\n\n```javascript\nconst shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];\nconst link = shape.getLink();\nif (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_POSITION) {\n Logger.log(\n `Shape has link to slide with relative position: ${\n link.getSlidePosition()}`,\n );\n}\n```\n\n#### Return\n\n\n[SlidePosition](/apps-script/reference/slides/slide-position)\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Url()`\n\nReturns the URL to the external web page or `null` if the [LinkType](/apps-script/reference/slides/link-type) is not [LinkType.URL](/apps-script/reference/slides/link-type#URL).\n\n```javascript\nconst shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];\nconst link = shape.getLink();\nif (link != null && link.getLinkType() === SlidesApp.LinkType.URL) {\n Logger.log(`Shape has link to URL: ${link.getUrl()}`);\n}\n```\n\n#### Return\n\n\n`String`\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`"]]