# Open New Window/Tab via API

**URL:** https://meta.discourse.org/t/open-new-window-tab-via-api/143964
**Category:** Support
**Created:** [March 11, 2020, 9:01pm UTC](https://meta.discourse.org/t/open-new-window-tab-via-api/143964 "2020-03-11T21:01:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![olegbc1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olegbc1/32/154008_2.png) [@olegbc1](https://meta.discourse.org/u/olegbc1)
#### Post date: [March 11, 2020, 9:01pm UTC](https://meta.discourse.org/t/open-new-window-tab-via-api/143964/1 "2020-03-11T21:01:34Z")

</div>

Hello, I’ve customized my instace of discourse to take a user to a specific page when they click on the community logo in the top right. It’s just a customized theme, in the header section:

```
<script type="text/discourse-plugin" version="0.4">
  api.changeWidgetSetting('home-logo', 'href', 'https://custom-url-here')
</script>

```

is there any way to make it open the url in the new browser tab?

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [March 11, 2020, 9:59pm UTC](https://meta.discourse.org/t/open-new-window-tab-via-api/143964/2 "2020-03-11T21:59:38Z")

</div>

This may help.

> [@Customized header link target attribute being ignored](https://meta.discourse.org/t/customized-header-link-target-attribute-being-ignored/57380/7):
>
> Oh this is interesting, if you take that code and change it to \<script type="text/discourse-plugin" version="0.4"\> api.decorateWidget('header-buttons:after', helper =\> { const showExtraInfo = helper.attrs.minimized; if(!showExtraInfo) { return helper.h('a.blog-link', {href:'https://blog.example.com', target:'\_blank'}, 'Visit our blog'); } }); \</script\> It will open in a new window just fine. So there seems to be a difference in how the clicks are handled when i…

---

<div class="post-metadata">

### Author: ![olegbc1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olegbc1/32/154008_2.png) [@olegbc1](https://meta.discourse.org/u/olegbc1)
#### Post date: [March 11, 2020, 11:12pm UTC](https://meta.discourse.org/t/open-new-window-tab-via-api/143964/3 "2020-03-11T23:12:58Z")

</div>

Thanks for the sugestion! I have checked the thread you linked and added a `, target:'_blank'` to api.changeWidgetSetting. Unfortunately this causes an error and clicking on the top logo takes you back to discourse homepage -

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/7/1773fb65bb78548f5ccc7547b82ea0fed64a3c8d.png)

---

<div class="post-metadata">

### Author: ![jordan.vidrine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan.vidrine/32/515563_2.png) [@jordan.vidrine](https://meta.discourse.org/u/jordan.vidrine)
#### Post date: [March 12, 2020, 1:42pm UTC](https://meta.discourse.org/t/open-new-window-tab-via-api/143964/4 "2020-03-12T13:42:57Z")

</div>

The code below was taken from a reply marked as a solution in a previous topic.

```xml
<script type="text/discourse-plugin" version="0.4">
api.decorateWidget('header-buttons:after', helper => { 
const showExtraInfo = helper.attrs.minimized; 
if (!showExtraInfo) { 
return helper.h('a.blog-link', {href:'https://blog.example.com', target:'_blank'}, 'Visit our blog'); } 

});
 </script>

```

> [@Customized header link target attribute being ignored](https://meta.discourse.org/t/customized-header-link-target-attribute-being-ignored/57380/3):
>
> I placed that in the Customize → CSS/HTML → `</head>` section. Running 1.8.0 beta4 (upgrading to beta5 to see if it helps).

did you visit [this topic reply?](https://meta.discourse.org/t/customized-header-link-target-attribute-being-ignored/57380/3)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [April 11, 2020, 1:43pm UTC](https://meta.discourse.org/t/open-new-window-tab-via-api/143964/5 "2020-04-11T13:43:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
