google.script.history는 상호작용할 수 있는 비동기 클라이언트 측 JavaScript API입니다. 확인할 수 있습니다 이는 IFRAME 부가기능의 사이드바 및 대화상자와 함께 사용하도록 만들어지지 않았습니다. container-script 컨텍스트를 사용하세요. 자세한 내용은 브라우저 사용 가이드 기록을 참조하세요.
제공된 상태 객체, URL 매개변수 및 URL 프래그먼트를 브라우저 기록에 푸시합니다. 있습니다 상태 객체는 개발자가 정의하고 앱의 현재 상태와 관련된 모든 데이터를 포함합니다. 이 메서드는 pushState() JavaScript 메서드와 함께 사용할 수 있습니다.
index.html
var now = new Date(); var state = { 'timestamp': now.getTime() }; var params = { 'options': "none" }; google.script.history.push(state, params, "anchor1");
매개변수
이름
유형
설명
stateObject
Object
개발자가 정의하고 브라우저 기록 이벤트와 연결되어 있으며, 상태가 표시되면 다시 표시됩니다. 보통 향후 검색을 위해 애플리케이션 상태 정보 (예: 페이지 데이터)를 저장하는 데 사용됩니다.
params
Object
이 상태와 관련이 있습니다. 예를 들어 {foo: “bar”, fiz: “baz”}는 "?foo=bar&fiz=baz"입니다. 또는 배열을 사용할 수 있습니다. {foo: [“bar”, “cat”], fiz: “baz”}는 "?foo=bar&foo=cat&fiz=baz"와 같습니다. null이거나 정의되지 않은 경우 현재 URL 매개변수는 변경되지 않습니다. 비워 두면 URL 매개변수가 삭제되었습니다.
hash
String
문자열 URL 조각이 '#' 있습니다. null이거나 정의되지 않은 경우 현재 URL 조각이 변경되지 않습니다. 비어 있으면 URL 조각이 삭제되었습니다.
replace(stateObject, params, hash)
브라우저 기록 스택의 상위 이벤트를 제공된 (개발자 정의) 상태로 대체합니다. 객체, URL 매개변수 및 URL 프래그먼트입니다. 그 외에는 다음과 동일합니다. push()를 사용하여 푸시 알림을 받을 수 있습니다.
index.html
var now = new Date(); var state = { 'timestamp': now.getTime() }; var params = { 'options': "none" }; google.script.history.replace(state, params, "anchor1");
매개변수
이름
유형
설명
stateObject
Object
개발자가 정의하고 브라우저 기록 이벤트와 연결되어 있으며, 상태가 표시되면 다시 표시됩니다. 보통 향후 검색을 위해 애플리케이션 상태 정보 (예: 페이지 데이터)를 저장하는 데 사용됩니다.
params
Object
이 상태와 관련이 있습니다. 예를 들어 {foo: “bar”, fiz: “baz”}는 "?foo=bar&fiz=baz"입니다. 또는 배열을 사용할 수 있습니다. {foo: [“bar”, “cat”], fiz: “baz”}는 "?foo=bar&foo=cat&fiz=baz"와 같습니다. null이거나 정의되지 않은 경우 현재 URL 매개변수는 변경되지 않습니다. 비워 두면 URL 매개변수가 삭제되었습니다.
hash
String
문자열 URL 조각이 '#' 있습니다. null이거나 정의되지 않은 경우 현재 URL 조각이 변경되지 않습니다. 비어 있으면 URL 조각이 삭제되었습니다.
setChangeHandler(function)
브라우저 기록 변경에 응답하도록 콜백 함수를 설정합니다. 콜백 함수 단일 이벤트 객체만 인수로 사용해야 합니다.
index.html
google.script.history.setChangeHandler(function (e) { console.log(e.state); console.log(e.location.parameters); console.log(e.location.hash); // Adjust web app UI to match popped state here... });
매개변수
이름
유형
설명
function
Function
클라이언트 측 다음을 사용하여 기록 변경 이벤트 시 실행되도록 합니다. 이벤트 객체를 유일한 인수로 사용합니다.
이벤트 객체
필드
e.state
표시된 이벤트와 연결된 상태 객체입니다. 이 객체는 객체에 추가된 push() 또는 표시된 상태를 추가한 replace() 메서드 기록 스택에 저장됩니다
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003egoogle.script.history\u003c/code\u003e enables interaction with the browser history stack within web apps using \u003ccode\u003eIFRAME\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to push, replace, and monitor browser history state, including URL parameters and fragments.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can define custom state objects to store and retrieve application-specific data associated with history events.\u003c/p\u003e\n"],["\u003cp\u003eA change handler can be set to trigger a callback function in response to history changes, allowing dynamic UI updates.\u003c/p\u003e\n"]]],[],null,["`google.script.history` is an asynchronous client-side JavaScript API that can interact\nwith the browser history stack. It can only be used in the context of a web app that uses\n[`IFRAME`](/apps-script/reference/html/sandbox-mode#properties).\nIt is not intended for use with sidebars and dialogs in an add-on or\ncontainer-script context. For more information, see the\n[guide to using browser\nhistory in web apps](/apps-script/guides/web#web_apps_and_browser_history). \n\nMethods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------------------------|-------------|----------------------------------------------------------------------------------------------------------------------|\n| [push(stateObject, params, hash)](#push(Object,Object,String)) | `void` | Pushes the provided state object, URL parameters and URL fragment onto the browser history stack. |\n| [replace(stateObject, params, hash)](#replace(Object,Object,String)) | `void` | Replaces the top event on the browser history stack with the provided state object, URL parameters and URL fragment. |\n| [setChangeHandler(function)](#setChangeHandler(Function)) | `void` | Sets a callback function to respond to changes in the browser history |\n\nDetailed documentation \n\n`push(stateObject, params, hash)`\n\nPushes the provided state object, URL parameters and URL fragment onto the browser history\nstack. The state object is a simple JavaScript Object that is defined by the developer and can\ncontain any data relevant to the app's current state. This method is analogous to the\n[pushState()](https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method)\nJavaScript method. \n\nIndex.html \n\n```html\nvar now = new Date();\nvar state = {\n 'timestamp': now.getTime()\n};\nvar params = {\n 'options': \"none\"\n};\ngoogle.script.history.push(state, params, \"anchor1\");\n```\n\nParameters\n\n| Name | Type | Description |\n|---------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `stateObject` | `Object` | An developer-defined object to be associated with a browser history event, and which resurfaces when the state is popped. Typically used to store application state information (such as page data) for future retrieval. |\n| `params` | `Object` | An object containing URL parameters to associate with this state. For example, `{foo: \"bar\", fiz: \"baz\"}` equates to `\"?foo=bar&fiz=baz\"`. Alternatively, arrays can be used: `{foo: [\"bar\", \"cat\"], fiz: \"baz\"}` equates to `\"?foo=bar&foo=cat&fiz=baz\"`. If null or undefined, the current URL parameters are not changed. If empty, the URL parameters are cleared. |\n| `hash` | `String` | The string URL fragment appearing after the '#' character. If null or undefined, the current URL fragment is not changed. If empty, the URL fragment is cleared. |\n\n*** ** * ** ***\n\n*** ** * ** ***\n\n`replace(stateObject, params, hash)`\n\nReplaces the top event on the browser history stack with the provided (developer-defined) state\nobject, URL parameters and URL fragment. This is otherwise identical to\n[push()](#push(Object,Object,String)). \n\nIndex.html \n\n```html\nvar now = new Date();\nvar state = {\n 'timestamp': now.getTime()\n};\nvar params = {\n 'options': \"none\"\n};\ngoogle.script.history.replace(state, params, \"anchor1\");\n```\n\nParameters\n\n| Name | Type | Description |\n|---------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `stateObject` | `Object` | An developer-defined object to be associated with a browser history event, and which resurfaces when the state is popped. Typically used to store application state information (such as page data) for future retrieval. |\n| `params` | `Object` | An object containing URL parameters to associate with this state. For example, `{foo: \"bar\", fiz: \"baz\"}` equates to `\"?foo=bar&fiz=baz\"`. Alternatively, arrays can be used: `{foo: [\"bar\", \"cat\"], fiz: \"baz\"}` equates to `\"?foo=bar&foo=cat&fiz=baz\"`. If null or undefined, the current URL parameters are not changed. If empty, the URL parameters are cleared. |\n| `hash` | `String` | The string URL fragment appearing after the '#' character. If null or undefined, the current URL fragment is not changed. If empty, the URL fragment is cleared. |\n\n*** ** * ** ***\n\n`setChangeHandler(function)`\n\nSets a callback function to respond to changes in the browser history. The callback function\nshould take only a single [event object](#eventObject) as an argument.\n\nIndex.html \n\n```html\ngoogle.script.history.setChangeHandler(function (e) {\n console.log(e.state);\n console.log(e.location.parameters);\n console.log(e.location.hash);\n\n // Adjust web app UI to match popped state here...\n});\n```\n\nParameters\n\n| Name | Type | Description |\n|------------|------------|----------------------------------------------------------------------------------------------------------------------------------|\n| `function` | `Function` | a client-side callback function to run upon a history change event, using the [event object](#eventObject) as the only argument. |\n\nEvent object\n\n| Fields ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `e.state` | The state object associated with the popped event. This object is identical to the state object that used in the corresponding [push()](#push(Object,Object,String)) or [replace()](#replace(Object,Object,String)) method that added the popped state to the history stack. ``` {\"page\":2, \"name\":\"Wilbur\"} ``` |\n| `e.location` | A [location object](/apps-script/guides/html/reference/url#locationObject) associated with the popped event ``` {\"hash\":\"\", \"parameter\":{\"name\": \"alice\", \"n\": \"1\"}, \"parameters\":{\"name\": [\"alice\"], \"n\": [\"1\", \"2\"]}} ``` |\n\n*** ** * ** ***"]]