google.script.url 클래스 (클라이언트 측 API)
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
google.script.url
는 비동기 클라이언트 측 JavaScript입니다.
URL을 쿼리하여 현재 URL 매개변수 및 프래그먼트를 가져올 수 있는 API입니다.
이 API는 google.script.history
API에 액세스할 수 있습니다. 이는
IFRAME
부가기능의 사이드바 및 대화상자와 함께 사용하도록 만들어지지 않았습니다.
container-script 컨텍스트를 사용하세요. 자세한 내용은
브라우저 사용 가이드
기록을 참조하세요.
자세한 문서
getLocation(function)
URL 위치 객체를 가져와서 지정된 콜백에 전달합니다.
(유일한 인수로)
index.html
google.script.url.getLocation(function(location) {
console.log(location.parameters);
console.log(location.hash);
});
매개변수
이름 | 유형 | 설명 |
function | Function | 클라이언트 측
를 사용하여 실행할 콜백 함수를
location 객체를 유일한 인수로 사용합니다.
|
위치 객체
다음 표는
다음 URL이 쿼리되었습니다.
http://www.example.com?n=1&name=alice&n=2#headingAnchor
필드 |
location.hash |
# 문자 뒤에 오는 URL 프래그먼트의 문자열 값입니다.
또는 URL 조각이 없는 경우 빈 문자열
headingAnchor
|
location.parameter |
URL 요청에 해당하는 키-값 쌍의 객체입니다.
매개변수입니다. 매개변수의 경우 첫 번째 값만 반환됩니다.
여러 개의 값을 가질 수 있습니다. 매개변수가 없으면
빈 객체여야 합니다.
{"name": "alice", "n": "1"}
|
location.parameters |
location.parameter 와 비슷하지만
각 키의 값 배열입니다. 매개변수가 없으면
빈 객체여야 합니다.
{"name": ["alice"], "n": ["1", "2"]}
|
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003egoogle.script.url\u003c/code\u003e is a client-side JavaScript API for querying URLs to get parameters and fragments within web apps.\u003c/p\u003e\n"],["\u003cp\u003eThis API works with \u003ccode\u003egoogle.script.history\u003c/code\u003e and requires the use of \u003ccode\u003eIFRAME\u003c/code\u003e in your web app.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetLocation()\u003c/code\u003e method retrieves a URL location object containing parameters and hash information, passing it to a callback function.\u003c/p\u003e\n"],["\u003cp\u003eThe location object provides access to URL components like hash, individual parameters, and all parameter values.\u003c/p\u003e\n"]]],[],null,["# Class google.script.url (Client-side API)\n\n`google.script.url` is an asynchronous client-side JavaScript\nAPI that can query URLs to obtain the current URL parameters and fragment.\nThis API supports the [`google.script.history`](/apps-script/guides/html/reference/history)\nAPI. 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\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------|-------------|------------------------------------------------------------------------------|\n| [getLocation(function)](#getLocation(Function)) | `void` | Gets a URL location object and passes it to the specified callback function. |\n\nDetailed documentation\n----------------------\n\n### `getLocation(function)`\n\nGets a [URL location object](#locationObject) and passes it to the specified callback\nfunction (as the only argument). \n\n### Index.html\n\n```html\ngoogle.script.url.getLocation(function(location) {\n console.log(location.parameters);\n console.log(location.hash);\n});\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|------------|------------|------------------------------------------------------------------------------------------------------------|\n| `function` | `Function` | a client-side callback function to run, using the [location object](#locationObject) as the only argument. |\n\n#### Location object\n\nThe following table shows examples of the location elements that would be specified if the following URL was queried: `http://www.example.com?n=1&name=alice&n=2#headingAnchor`\n\n| Fields ||\n|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `location.hash` | The string value of URL fragment after the `#` character, or an empty string if no URL fragment is present ``` headingAnchor ``` |\n| `location.parameter` | An object of key/value pairs that correspond to the URL request parameters. Only the first value will be returned for parameters that have multiple values. If no parameters are present, this will be an empty object. ``` {\"name\": \"alice\", \"n\": \"1\"} ``` |\n| `location.parameters` | An object similar to `location.parameter`, but with an array of values for each key. If no parameters are present, this will be an empty object. ``` {\"name\": [\"alice\"], \"n\": [\"1\", \"2\"]} ``` |\n\n*** ** * ** ***"]]