{"result":{"depiction_url":null,"edges":{"subject":{"objects":[{"created":"2026-09-30T09:11:23Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-30T09:11:23Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-30T09:11:23Z","object_id":{"id":2625,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_model","title":"Model","uri":"https:\/\/zotonic.com\/id\/2625"},"seq":3},{"created":"2026-09-30T09:11:23Z","object_id":{"id":2673,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_javascript","title":"JavaScript","uri":"https:\/\/zotonic.com\/id\/2673"},"seq":4},{"created":"2026-09-30T09:11:23Z","object_id":{"id":2714,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_browser_navigation","title":"Browser navigation","uri":"https:\/\/zotonic.com\/id\/2714"},"seq":5},{"created":"2026-09-30T09:11:23Z","object_id":{"id":2718,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_cotonic","title":"Cotonic","uri":"https:\/\/zotonic.com\/id\/2718"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":2736,"is_a":["text","documentation","reference","cotonic_reference","cotonic_model"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2736"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_cotonic_model_location","page_url":{"en":"https:\/\/zotonic.com\/cotonic\/models\/location","x-default":"https:\/\/zotonic.com\/cotonic\/models\/location"},"preview_url":null,"resource":{"version":15,"pivot_location_lat":null,"title":"model\/location","is_authoritative":true,"body":"<a name=\"model.location\"><\/a><h3>model\/location<\/h3>\n            <p>\n            The location model can be used to retrieve information on the current location\n            of the page. It also allows subscription to location changes.\n            <\/p>\n\n            <!-- get\/href -->\n            <a name=\"model.location.get.href\"><\/a><h4>get\/href<\/h4><p>\n            Get the current href.\n            <\/p>\n            <pre>\nself.call(&quot;model\/location\/get\/href&quot;)\n.then(function(m) {\n    console.log(m.payload)\n});\n=&gt; &quot;https:\/\/cotonic.org\/#model.location&quot;<\/pre>\n\n            <!-- get\/protocol -->\n            <a name=\"model.location.get.protocol\"><\/a><h4>get\/protocol<\/h4><p>\n            Get the current protocol\n            <\/p>\n            <pre>\nself.call(&quot;model\/location\/get\/protocol&quot;)\n.then(function(m) {\n    console.log(m.payload)\n});\n=&gt; &quot;https&quot;<\/pre>\n\n            <!-- get\/host -->\n            <a name=\"model.location.get.host\"><\/a><h4>get\/host<\/h4><p>\n            Get the current host (with port).\n            <\/p>\n            <pre>\nself.call(&quot;model\/location\/get\/host&quot;)\n.then(function(m) {\n    console.log(m.payload)\n});\n=&gt; &quot;cotonic.org&quot;<\/pre>\n\n            <!-- get\/hostname -->\n            <a name=\"model.location.get.hostname\"><\/a><h4>get\/hostname<\/h4><p>\n            <\/p>\n            Get the current hostname (without port).\n            <pre>\nself.call(&quot;model\/location\/get\/hostname&quot;)\n.then(function(m) {\n    console.log(m.payload)\n});\n=&gt; &quot;cotonic.org&quot;<\/pre>\n\n            <!-- get\/origin -->\n            <a name=\"model.location.get.origin\"><\/a><h4>get\/origin<\/h4><p>\n            Get the current origin.\n            <\/p>\n            <pre>\nself.call(&quot;model\/location\/get\/origin&quot;)\n.then(function(m) {\n    console.log(m.payload)\n});\n=&gt; &quot;https:\/\/cotonic.org&quot;<\/pre>\n\n            <!-- get\/pathname -->\n            <a name=\"model.location.get.pathname\"><\/a><h4>get\/pathname<\/h4><p>\n            Get the current pathname.\n            <\/p>\n            <pre>\nself.call(&quot;model\/location\/get\/pathname&quot;)\n.then(function(m) {\n    console.log(m.payload)\n});\n=&gt; &quot;\/&quot;<\/pre>\n\n            <!-- get\/port -->\n            <a name=\"model.location.get.port\"><\/a><h4>get\/port<\/h4><p>\n            Get the current port.\n            <\/p>\n            <pre>\ncotonic.broker.call(&quot;model\/location\/get\/port&quot;)\n.then(function(m) {\n    console.log(m.payload)\n})\n=&gt; &quot;&quot; \/\/ The default port.<\/pre>\n\n\n            <!-- post\/redirect -->\n\n <a name=\"model.location.post.redirect\"><\/a><h4>post\/redirect<\/h4><p>\n            Redirect the user to another url\n            <\/p>\n            <pre>\ncotonic.broker.publish(&quot;model\/location\/post\/redirect&quot;, {url: &quot;https:\/\/cotonic.org&quot;})\n=&gt; \/\/ The user is redirect to cotonic.org.<\/pre>\n\n            <!-- post\/redirect\/back -->\n\n<a name=\"model.location.post.redirect.back\"><\/a><h4>post\/redirect\/back<\/h4><p>\n            Loads the previous URL (page) in the history list. When there is no page in the\n            history list, a default (local) url can be passed. When no navigation occurs, \n            the user will be redirected to this url.\n<\/p>\n<pre>\ncotonic.broker.publish(&quot;model\/location\/post\/redirect\/back&quot;, {url: &quot;\/home&quot;})\n=&gt; \/\/ Go back, when there is no page in the history, move to &quot;\/home&quot;.<\/pre>\n\n<pre>\n&lt;a data-onclick-topic=&quot;model\/location\/post\/redirect\/back&quot; href=&quot;\/home&quot;&gt;Go Back&lt;\/a&gt;\n<\/pre>\n\n            <!-- post\/reload -->\n\n <a name=\"model.location.post.reload\"><\/a><h4>post\/reload<\/h4><p>\n            Reload the current page. This can be handy when you know something on the server side has\n            changed.\n            <\/p>\n            <pre>\ncotonic.broker.call(&quot;model\/location\/post\/reload&quot;)\n=&gt; \/\/ The page will reload.\n<\/pre>\n\n<pre>\n&lt;button data-onclick-topic=&quot;bridge\/origin\/model\/xyz\/post\/doit&quot;\n        data-onresponse-topic=&quot;model\/location\/reload&quot;&gt;Do It&lt;\/button&gt;\n\nWhen the xyz model on the server responds, the page will be reloaded\n            <\/pre>\n\n            <!-- post\/q -->\n\n <a name=\"model.location.post.q\"><\/a><h4>post\/q<\/h4><p>\n            Updates the current location’s search (query) arguments with the given object of\n            <tt>{ &quot;key&quot;: value }<\/tt> keys. The browsers location is modified using <tt>replaceState<\/tt>\n            and the new arguments are posted to <tt>model\/location\/event\/q<\/tt> and <tt>model\/location\/event\/qlist<\/tt>\n            <\/p>\n            <p>If you need to have multiple keys with the same name, or the order of the keys is significant then use <a href=\"\/id\/doc_cotonic_model_location#model.location.post.qlist\">post\/qlist<\/a>.<\/p>\n            <pre>\ncotonic.broker.call(&quot;model\/location\/post\/q&quot;, {&quot;a&quot;:&quot;1&quot;, &quot;b&quot;:&quot;2&quot;} ])\n=&gt; \/\/ The browser location will be updated, the page is not reloaded\n<\/pre>\n\n<pre>\n&lt;form data-onsubmit-topic=&quot;model\/location\/post\/q&quot;&gt;\n   &lt;input type=&quot;text&quot; value=&quot;&quot;&gt;\n   &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;\n&lt;\/form&gt;\n            <\/pre>\n\n            <!-- post\/qlist -->\n\n <a name=\"model.location.post.qlist\"><\/a><h4>post\/qlist<\/h4><p>\n            Updates the current location’s search (query) arguments with the given list of\n            <tt>[Key, Value]<\/tt> pairs. The browsers location is modified using <tt>replaceState<\/tt>\n            and the new arguments are posted to <tt>model\/location\/event\/q<\/tt> and <tt>model\/location\/event\/qlist<\/tt>\n            <\/p>\n            <pre>\ncotonic.broker.call(&quot;model\/location\/post\/qlist&quot;, [ [&quot;a&quot;, &quot;1&quot;], [&quot;b&quot;, &quot;2&quot;] ])\n=&gt; \/\/ The browser location will be updated, the page is not reloaded\n<\/pre>\n\n<pre>\n&lt;form data-onsubmit-topic=&quot;model\/location\/post\/qlist&quot;&gt;\n   &lt;input type=&quot;text&quot; value=&quot;&quot;&gt;\n   &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;\n&lt;\/form&gt;\n            <\/pre>\n\n            <!-- post\/push -->\n\n <a name=\"model.location.post.push\"><\/a><h4>post\/push<\/h4><p>\n            Updates the current location with the given url. The new location is set using\n            <tt>pushState<\/tt>, so the back button will work. The location is assumed to be\n            on the same hostname as the current page, so only the new path, search and hash are\n            pushed.<br \/>\n            If parts of the new location are changed then they are posted to <tt>model\/location\/event\/pathname<\/tt>, <tt>model\/location\/event\/q<\/tt>, <tt>model\/location\/event\/qlist<\/tt> and <tt>model\/location\/event\/hash<\/tt>.  If the hash is set and there is an element with an id corresponding to the hash, then that element is scrolled into view.\n            <\/p>\n<pre>\ncotonic.broker.call(&quot;model\/location\/post\/push&quot;, { url: &quot;\/hello?w=world&quot; });\n=&gt; \/\/ The browser location will be updated, the page is not reloaded\n<\/pre>\n\n<pre>\n&lt;a data-onclick-topic=&quot;model\/location\/post\/push&quot; href=&quot;?a=1&quot;&gt;\n<\/pre>\n\n            <!-- post\/replace -->\n\n <a name=\"model.location.post.replace\"><\/a><h4>post\/replace<\/h4><p>\n            Updates the current location with the given url. The new location is set using\n            <tt>replaceState<\/tt>, so the back button will NOT work. The location is assumed to be\n            on the same hostname as the current page, so only the new path, search and hash are\n            pushed.<br \/>\n            If parts of the new location are changed then they are posted to <tt>model\/location\/event\/pathname<\/tt>, <tt>model\/location\/event\/q<\/tt>, <tt>model\/location\/event\/qlist<\/tt> and <tt>model\/location\/event\/hash<\/tt>.  If the hash is set and there is an element with an id corresponding to the hash, then that element is scrolled into view.\n            <\/p>\n<pre>\ncotonic.broker.call(&quot;model\/location\/post\/replace&quot;, { url: &quot;\/hello?w=world&quot; });\n=&gt; \/\/ The browser location will be updated, the page is not reloaded\n<\/pre>\n\n<pre>\n&lt;a data-onclick-topic=&quot;model\/location\/post\/replace&quot; href=&quot;?a=1&quot;&gt;\n<\/pre>\n\n\n            <!-- post\/push-silent -->\n\n <a name=\"model.location.post.push-silent\"><\/a><h4>post\/push-silent<\/h4><p>\n            Updates the current location with the given url. The new location is set using\n            <tt>pushState<\/tt>, so the back button will work. The location is assumed to be\n            on the same hostname as the current page, so only the new path, search and hash are\n            pushed.<br \/>\n            The new location is silently changed, no location events are published.\n            <\/p>\n<pre>\ncotonic.broker.call(&quot;model\/location\/post\/push-silent&quot;, { url: &quot;\/hello?w=world&quot; });\n=&gt; \/\/ The browser location will be updated, the page is not reloaded\n<\/pre>\n\n<pre>\n&lt;a data-onclick-topic=&quot;model\/location\/post\/push-silent&quot; href=&quot;?a=1&quot;&gt;\n<\/pre>\n\n            <!-- post\/replace-silent -->\n\n <a name=\"model.location.post.replace-silent\"><\/a><h4>post\/replace-silent<\/h4><p>\n            Updates the current location with the given url. The new location is set using\n            <tt>replaceState<\/tt>, so the back button will NOT work. The location is assumed to be\n            on the same hostname as the current page, so only the new path, search and hash are\n            pushed.<br \/>\n            The new location is silently changed, no location events are published.\n            <\/p>\n<pre>\ncotonic.broker.call(&quot;model\/location\/post\/replace-silent&quot;, { url: &quot;\/hello?w=world&quot; });\n=&gt; \/\/ The browser location will be updated, the page is not reloaded\n<\/pre>\n\n<pre>\n&lt;a data-onclick-topic=&quot;model\/location\/post\/replace-silent&quot; href=&quot;?a=1&quot;&gt;\n<\/pre>\n\n            <!-- event\/search -->\n            <a name=\"model.location.event.search\"><\/a><h4>event\/search<\/h4><p>\n            A message containing the query string part of the url will be published when it changes.\n            <em>Note: the message is retained<\/em>\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/location\/event\/search&quot;,\n    function(m, a) {\n        console.log(&quot;query string changed&quot;, m.payload);\n});<\/pre>\n\n            <!-- event\/pathname -->\n            <a name=\"model.location.event.pathname\"><\/a><h4>event\/pathname<\/h4><p>\n            A message containing the pathname part of the url will be published when it changes.\n            <em>Note: the message is retained<\/em>\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/location\/event\/pathname&quot;,\n    function(m, a) {\n        console.log(&quot;pathname changed&quot;, m.payload);\n    });<\/pre>\n\n            <!-- event\/hash -->\n            <a name=\"model.location.event.hash\"><\/a><h4>event\/hash<\/h4><p>\n            A message containing the hash part of the url will be published when it changes.\n            <em>Note: the message is retained<\/em>\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/location\/event\/hash&quot;,\n    function(m, a) {\n        console.log(&quot;hash changed&quot;, m.payload);\n    });<\/pre>\n\n            <!-- event\/ping -->\n            <a name=\"model.location.event.ping\"><\/a><h4>event\/ping<\/h4><p>\n            When the location model is enabled, a retained message is published on this\n            topic. By subscribing to this topic it is possible to see when the model is\n            enabled. The payload of the message <tt>pong<\/tt>.\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/location\/event\/ping&quot;,\n    function(m) {\n        console.log(&quot;The location model is enabled&quot;, m.payload)\n    })\n=&gt; Logs a message on the console when the location model is enabled.<\/pre>\n\n            <!-- event\/q -->\n            <a name=\"model.location.event.q\"><\/a><h4>event\/q<\/h4><p>\n            A message with the current query arguments is published on this\n            topic. By subscribing to this topic it is possible to see when the query arguments\n            change. The payload of the message is an object with <tt>{ &quot;key&quot;: &quot;value&quot; }<\/tt>\n            entries. <em>Note: the message is retained<\/em>\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/location\/event\/q&quot;,\n    function(m) {\n        console.log(&quot;New query arguments&quot;, m.payload)\n    })\n=&gt; Logs a message on the console when the query arguments change.<\/pre>\n\n            <!-- event\/qlist -->\n            <a name=\"model.location.event.qlist\"><\/a><h4>event\/qlist<\/h4><p>\n            A message with the current query arguments is published on this\n            topic. By subscribing to this topic it is possible to see when the query arguments\n            change. The payload of the message is an array with <tt>[ &quot;key&quot;, &quot;value&quot; ]<\/tt> pairs.\n            <em>Note: the message is retained<\/em>\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/location\/event\/qlist&quot;,\n    function(m) {\n        console.log(&quot;New query arguments&quot;, m.payload)\n    })\n=&gt; Logs a message on the console when the query arguments change.<\/pre>\n\n            <!-- config -->\n            <a name=\"model.location.config\"><\/a><h4><em>Configuration<\/em><\/h4><p>\n            The location has one configuration option.\n            <\/p>\n            <dl>\n                <dt><tt>pathname_search<\/tt><\/dt>\n                <dd>Set to the current search parameters of the page. Alternatively this setting\n                can can be done as <tt>data-cotonic-pathname-search<\/tt> attribute on the body tag.<\/dd>\n            <\/dl>\n\n            <pre>\n&lt;script&gt;\n    window.cotonic = window.cotonic || {};\n    window.cotonic.config = {\n        start_service_worker: true,\n        pathname_search: &quot;q=110&amp;j=yes&quot;\n    };\n&lt;\/script&gt;\n&lt;script src=&quot;cotonic.js&quot;&gt;&lt;\/script&gt;\n<\/pre>\n            <pre>\n&lt;body data-cotonic-pathname-search=&quot;q=110&amp;amp;j=yes&quot;&gt;\n...\n&lt;\/body&gt;\n<\/pre>\n\n            ","slug":"model-location","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"c8615a5eaca7f49cc03b96369b37cc3a7497a4b03c9dabe65914f49114a4255b","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":2723,"is_a":["meta","category"],"name":"cotonic_model","title":"Cotonic models","uri":"https:\/\/zotonic.com\/id\/cotonic_model"},"doc_source_path":"index.html","publication_start":"2026-09-30T09:11:23Z","page_path":"\/cotonic\/models\/location","github_url":"https:\/\/github.com\/cotonic\/cotonic\/blob\/master\/index.html","pivot_location_lng":null,"doc_source_kind":"cotonic","name":"doc_cotonic_model_location","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2026-09-30T09:11:23Z","uri":null,"doc_source_anchor":"model.location","doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"f88cc928b997d10f7f19e6bd0ede80e1c8c619bc","creator_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"modified":"2026-09-30T09:57:31Z","title_slug":"model-location"},"uri":"https:\/\/zotonic.com\/id\/2736","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2736"}},"status":"ok"}