ออบเจ็กต์ที่แสดงบุ๊กมาร์ก
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); // Insert a bookmark at the cursor position (in the active tab) and log its ID. const cursor = doc.getCursor(); const bookmark = documentTab.addBookmark(cursor); Logger.log(bookmark.getId());
เมธอด
| วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
|---|---|---|
get | String | รับรหัสของ Bookmark |
get | Position | ได้รับPositionของBookmarkภายในDocument |
remove() | void | ลบ Bookmark |
เอกสารโดยละเอียด
getId()
รับรหัสของ Bookmark รหัสจะไม่ซ้ำกันภายใน DocumentTab
รีเทิร์น
String - รหัสของ Bookmark ซึ่งไม่ซ้ำกันภายใน DocumentTab
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPosition()
ได้รับPositionของBookmarkภายในDocumentTab Position จะยังคงถูกต้องตราบใดที่ไม่ได้ลบ Bookmark แม้ว่าสคริปต์จะเปลี่ยนโครงสร้างเอกสารก็ตาม
รีเทิร์น
Position — ตำแหน่งของ Bookmark
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove()
ลบ Bookmark การเรียกใช้เมธอดนี้ใน Bookmark ที่ถูกลบไปแล้วจะไม่มีผล
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents