# model/window

Source: https://zotonic.com/cotonic/models/window

URI: https://zotonic.com/id/2734

Language: en



<a name="model.window"></a>
The window model can be used open and close windows.
<!-- post/open --> <a name="model.window.post.open"></a>
post/open
---------

Open a window. The payload of the message can be set t

<dl>
                <dt><tt>href</tt></dt>
                <dd>The url of the window. See below.</dd>
                <dt><tt>data-window</tt></dt>
                <dd>A JSON string containing properties described below.</dd>
            </dl>
Or
<dl>
                <dt><tt>url</tt></dt>
                <dd>The url of the page to open.</dd>
                <dt><tt>name</tt></dt>
                <dd>Specifies the target attribute of the window.
                  <dl>
                      <dt><tt>_blank</tt></dt><dd> opens a new window.</dd>
                      <dt><tt>_parent</tt></dt><dd> loads the url in the parent window.</dd>
                      <dt><tt>_self</tt></dt><dd> replaces the current page.</dd>
                      <dt><tt>_top</tt></dt><dd> replaces any frameset that maybe loaded.</dd>
                      <dt><tt>name</tt></dt><dd>the name of the window to load.</dd>
                  </dl>
                </dd>
                <dt><tt>width</tt></dt>
                <dd>The width of the window in pixels.</dd>
                <dt><tt>height</tt></dt>
                <dd>The height of the window in pixels.</dd>
                <dt><tt>toolbar</tt></dt>
                <dd>Wether or not to display the browsers toolbar.</dd>
                <dt><tt>scrollbars</tt></dt>
                <dd>Wether or not to display scrollbars.</dd>
                <dt><tt>status</tt></dt>
                <dd>Wether or not to add a status bar.</dd>
                <dt><tt>resizable</tt></dt>
                <dd>Wether or not the window is resizable.</dd>
                <dt><tt>location</tt></dt>
                <dd>Wether or not to display the address field.</dd>
                <dt><tt>menubar</tt></dt>
                <dd>Wether or not to display the menubar.</dd>
                <dt><tt>centerBrowser</tt></dt>
                <dd>Indicate wether or not to center the new window on top of the current active browser window.</dd>
                <dt><tt>centerScreen</tt></dt>
                <dd>Indicate wether or not to center the new window on the screen.</dd>
                <dt><tt>top</tt></dt>
                <dd>The top position of the window.</dd>
                <dt><tt>left</tt></dt>
                <dd>The left position of the window.</dd>
            </dl>

```
<a href="https://example.com/logon"
   class="btn btn-social"
   data-onclick-topic="model/window/post/open">Logon in with Example.com</a>
   data-window="{'centerBrowser': true}"
==> The click on the link publishes is window open message which will open
    a centered logon window.
```

```
self.publish("model/window/post/open", {url: "https://example.com/logon",
                                        centerBrowser: true})
==> A worker opens a logon window.
```
<a name="model.window.post.close"></a>
post/close
----------

Open a window.

```
<a href="#" class="btn btn-default"
      data-onclick-topic="model/window/post/close"> Close Window <a>
==> Closes the current window.
```
<!-- model document -->

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2734?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2734?language=en>)
