2021-06-17 18:05:16 +02:00
{.section-title.accent.text-primary}
# API Navigation functions reference
### Opening a web page in a new tab
2022-02-07 17:53:36 +01:00
```ts
2021-06-17 18:05:16 +02:00
WA.nav.openTab(url: string): void
```
Opens the webpage at "url" in your browser, in a new tab.
Example:
2022-02-07 17:53:36 +01:00
```ts
2021-06-17 18:05:16 +02:00
WA.nav.openTab('https://www.wikipedia.org/');
```
### Opening a web page in the current tab
2022-02-07 17:53:36 +01:00
```ts
2021-06-17 18:05:16 +02:00
WA.nav.goToPage(url: string): void
```
Opens the webpage at "url" in your browser in place of WorkAdventure. WorkAdventure will be completely unloaded.
Example:
2022-02-07 17:53:36 +01:00
```ts
2021-06-17 18:05:16 +02:00
WA.nav.goToPage('https://www.wikipedia.org/');
```
### Going to a different map from the script
2022-02-07 17:53:36 +01:00
```ts
2021-06-17 18:05:16 +02:00
WA.nav.goToRoom(url: string): void
```
Load the map at url without unloading workadventure
relative urls: "../subFolder/map.json[#start-layer-name]"
global urls: "/_/global/domain/path/map.json[#start-layer-name]"
Example:
2022-02-07 17:53:36 +01:00
```ts
2021-06-17 18:05:16 +02:00
WA.nav.goToRoom("/@/tcm/workadventure/floor0") // workadventure urls
WA.nav.goToRoom('../otherMap/map.json');
WA.nav.goToRoom("/_/global/< path to global map > .json#start-layer-2")
```
2021-10-12 10:38:49 +02:00
### Opening/closing web page in Co-Websites
2021-06-17 18:05:16 +02:00
2022-02-07 17:53:36 +01:00
```ts
WA.nav.openCoWebSite(url: string, allowApi?: boolean = false, allowPolicy?: string = "", percentWidth?: number, position?: number, closable?: boolean, lazy?: boolean): Promise< CoWebsite >
2021-06-17 18:05:16 +02:00
```
2022-02-07 17:53:36 +01:00
Opens the webpage at "url" in an iFrame (on the right side of the screen) or close that iFrame. `allowApi` allows the webpage to use the "IFrame API" and execute script (it is equivalent to putting the `openWebsiteAllowApi` property in the map). `allowPolicy` grants additional access rights to the iFrame. The `allowPolicy` parameter is turned into an [`allow` feature policy in the iFrame ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-allow ),widthPercent define the width of the main cowebsite beetween the min size and the max size (70% of the viewport), position in whitch slot the web page will be open, closable allow to close the webpage also you need to close it by the api and lazy
2022-01-10 10:43:57 +01:00
it's to add the cowebsite but don't load it.
2021-06-17 18:05:16 +02:00
Example:
2022-02-07 17:53:36 +01:00
```ts
2021-10-25 18:50:40 +02:00
const coWebsite = await WA.nav.openCoWebSite('https://www.wikipedia.org/');
2022-02-07 17:53:36 +01:00
const coWebsiteWorkAdventure = await WA.nav.openCoWebSite('https://workadventu.re/', true, "", 70, 1, true, true);
2021-06-17 18:05:16 +02:00
// ...
2021-10-25 18:50:40 +02:00
coWebsite.close();
2021-10-12 10:38:49 +02:00
```
2021-10-28 10:00:12 +02:00
### Get all Co-Websites
2021-10-12 10:38:49 +02:00
2022-02-07 17:53:36 +01:00
```ts
2021-10-25 18:50:40 +02:00
WA.nav.getCoWebSites(): Promise< CoWebsite [ ] >
2021-10-12 10:38:49 +02:00
```
2021-10-27 12:12:42 +02:00
Get all opened co-websites with their ids and positions.
2021-10-12 10:38:49 +02:00
Example:
2022-02-07 17:53:36 +01:00
```ts
2021-10-25 18:50:40 +02:00
const coWebsites = await WA.nav.getCowebSites();
2021-06-17 18:05:16 +02:00
```