Class Tab
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Tab
Google Docs दस्तावेज़ में मौजूद टैब.
// Get all of the first-level tabs (tabs that are not nested within a parent
// tab) in the document.
// TODO(developer): Replace the ID with your own.
const tabs = DocumentApp.openById('123abc').getTabs();
// Get a specific tab based on the tab ID.
// TODO(developer): Replace the IDs with your own.
const tab = DocumentApp.openById('123abc').getTab('123abc');
ज़्यादा जानकारी वाला दस्तावेज़
getChildTabs()
इस टैब में नेस्ट किए गए चाइल्ड टैब को वापस लाता है.
वापसी का टिकट
Tab[]
— इस टैब में नेस्ट किए गए चाइल्ड टैब.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getId()
टैब का आईडी दिखाता है.
वापसी का टिकट
String
— टैब का आईडी.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getIndex()
यह फ़ंक्शन, पैरंट टैब में मौजूद टैब का 0 पर आधारित इंडेक्स दिखाता है.
वापसी का टिकट
Integer
— पैरंट टैग में टैब का इंडेक्स.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTitle()
टैब का टाइटल दिखाता है.
वापसी का टिकट
String
— टैब का टाइटल.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getType()
टैब का टाइप दिखाता है.
इस तरीके का इस्तेमाल करके, Tab
के कॉन्टेंट टाइप का पता लगाएं. इसके बाद, asDocumentTab()
का इस्तेमाल करके, कॉन्टेंट को किसी खास टाइप पर कास्ट करें.
const tab = DocumentApp.getActiveDocument().getActiveTab();
// Use getType() to determine the tab's type before casting.
if (tab.getType() === DocumentApp.TabType.DOCUMENT_TAB) {
// It's a document tab, write some text to it.
tab.asDocumentTab().setText('Hello World!');
} else {
// There are currently no types other than DOCUMENT_TAB.
}
वापसी का टिकट
TabType
— टैब का टाइप.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eA tab is a structural element within a Google Docs document, allowing for organization and navigation within the document's content.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve all first-level tabs or a specific tab using its ID with the \u003ccode\u003eDocumentApp\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTab\u003c/code\u003e class provides methods for accessing tab properties like title, type, index, and child tabs, as well as retrieving the tab contents as a \u003ccode\u003eDocumentTab\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eMost \u003ccode\u003eTab\u003c/code\u003e methods require authorization with scopes such as \u003ccode\u003ehttps://www.googleapis.com/auth/documents.currentonly\u003c/code\u003e or \u003ccode\u003ehttps://www.googleapis.com/auth/documents\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the \u003ccode\u003egetType()\u003c/code\u003e method to determine the tab type before casting to a specific tab type like \u003ccode\u003eDocumentTab\u003c/code\u003e for further interaction.\u003c/p\u003e\n"]]],["This documentation outlines how to interact with tabs in Google Docs via scripting. Key actions include retrieving tabs, either all first-level tabs or a specific one by ID. You can then get a tab's `DocumentTab`, child tabs, ID, index, title, and type. The `getType()` method is crucial for determining the content before using `asDocumentTab()`. All these methods need authorization scopes like `documents.currentonly` or `documents`.\n"],null,["# Class Tab\n\nTab\n\nA tab within a Google Docs document.\n\n```javascript\n// Get all of the first-level tabs (tabs that are not nested within a parent\n// tab) in the document.\n// TODO(developer): Replace the ID with your own.\nconst tabs = DocumentApp.openById('123abc').getTabs();\n\n// Get a specific tab based on the tab ID.\n// TODO(developer): Replace the IDs with your own.\nconst tab = DocumentApp.openById('123abc').getTab('123abc');\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------|-------------------------------------------------------------|----------------------------------------------------------------------------------------------|\n| [asDocumentTab()](#asDocumentTab()) | [DocumentTab](/apps-script/reference/document/document-tab) | Retrieves the tab contents as a [DocumentTab](/apps-script/reference/document/document-tab). |\n| [getChildTabs()](#getChildTabs()) | [Tab[]](#) | Retrieves the child tabs nested within this tab. |\n| [getId()](#getId()) | `String` | Retrieves the ID of the tab. |\n| [getIndex()](#getIndex()) | `Integer` | Retrieves the 0-based index of the tab within the parent. |\n| [getTitle()](#getTitle()) | `String` | Retrieves the title of the tab. |\n| [getType()](#getType()) | [TabType](/apps-script/reference/document/tab-type) | Retrieves the type of tab. |\n\nDetailed documentation\n----------------------\n\n### `as``Document``Tab()`\n\nRetrieves the tab contents as a [DocumentTab](/apps-script/reference/document/document-tab).\n\n#### Return\n\n\n[DocumentTab](/apps-script/reference/document/document-tab) --- The tab as a [DocumentTab](/apps-script/reference/document/document-tab).\n\n*** ** * ** ***\n\n### `get``Child``Tabs()`\n\nRetrieves the child tabs nested within this tab.\n\n#### Return\n\n\n[Tab[]](#) --- The child tabs nested within this tab.\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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n### `get``Id()`\n\nRetrieves the ID of the tab.\n\n#### Return\n\n\n`String` --- The ID of the tab.\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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n### `get``Index()`\n\nRetrieves the 0-based index of the tab within the parent.\n\n#### Return\n\n\n`Integer` --- The index of the tab within the parent.\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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n### `get``Title()`\n\nRetrieves the title of the tab.\n\n#### Return\n\n\n`String` --- The title of the tab.\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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n### `get``Type()`\n\nRetrieves the type of tab.\n\nUse this method to determine the content type of this [Tab](#) before casting to the more\nspecific type using [asDocumentTab()](#asDocumentTab()).\n\n```javascript\nconst tab = DocumentApp.getActiveDocument().getActiveTab();\n// Use getType() to determine the tab's type before casting.\nif (tab.getType() === DocumentApp.TabType.DOCUMENT_TAB) {\n // It's a document tab, write some text to it.\n tab.asDocumentTab().setText('Hello World!');\n} else {\n // There are currently no types other than DOCUMENT_TAB.\n}\n```\n\n#### Return\n\n\n[TabType](/apps-script/reference/document/tab-type) --- The tab's 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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`"]]