# Trigger costum event within javascript code

**URL:** <https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543>\
**Category:** Need help\
**Created:** [May 10, 2021, 2:45pm UTC](https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543 "2021-05-10T14:45:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![e.plus.dev1](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@e.plus.dev1](https://forum.bubble.io/u/e.plus.dev1)\
**Post date:** [May 10, 2021, 2:45pm UTC](https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543/1 "2021-05-10T14:45:24Z")

</div>

Hi guys,

I’m using auth2 signin to my app with Discord.  
I want to open a new tab after the user signed in.  
I have a plugin for open url page in new tab, but when i’m using this plugin in the workflow after the signin, the browser blocks my new tab (a protection of broswers).  
I found a way to workaround the browser’s protection but I need to use JS code.  
What I found is something like that:

var win = window.open();  
win.location = ‘[https://example.com](https://example.com)’;  
win.opener = null;  
win.blur();  
window.focus();

The workaround is first open the new tab and then change it’s location.  
I want to trigger a custom event for signin between before win.location.  
Something link that:

var win = window.open();  
  
win.location = ‘[https://example.com](https://example.com)’;  
win.opener = null;  
win.blur();  
window.focus();

Can I trigger an event of bubble within javascript code?

---

<div class="post-metadata">

**Author:** ![robhblake](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robhblake/32/60625_2.png) [@robhblake](https://forum.bubble.io/u/robhblake)\
**Post date:** [May 10, 2021, 5:52pm UTC](https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543/2 "2021-05-10T17:52:17Z")

</div>

> [@e.plus.dev1](#):
>
> Can I trigger an event of bubble within javascript code?

Yes you can! Part of the free [Toolbox plugin](https://bubble.io/plugin/toolbox-1488796042609x768734193128308700) there is a “JavaScript to Bubble” tool. Check that out.

---

<div class="post-metadata">

**Author:** ![e.plus.dev1](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@e.plus.dev1](https://forum.bubble.io/u/e.plus.dev1)\
**Post date:** [May 11, 2021, 11:18am UTC](https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543/3 "2021-05-11T11:18:29Z")

</div>

I used this plugin but didn’t know I can trigger an event. Thanks man!

---

<div class="post-metadata">

**Author:** ![alex.pethick](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/alex.pethick/32/75019_2.png) [@alex.pethick](https://forum.bubble.io/u/alex.pethick)\
**Post date:** [June 1, 2021, 7:40pm UTC](https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543/4 "2021-06-01T19:40:20Z")

</div>

@e.plus.dev1 @robhblake I’ve seen a few threads saying it’s possible with the Toolbox plugin now, but I haven’t seen anyone explain how that’s done. How do you do it?

Really appreciate any guidance. Thanks.

---

<div class="post-metadata">

**Author:** ![robhblake](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robhblake/32/60625_2.png) [@robhblake](https://forum.bubble.io/u/robhblake)\
**Post date:** [June 1, 2021, 8:01pm UTC](https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543/5 "2021-06-01T20:01:13Z")

</div>

Hey Alex,

You can check out [the plugin author’s post](http://forum.bubble.io/t/toolbox-plugin-collection-of-utility-elements/11264) explaining how to use the feature. Just install the plugin, place the “Javascript to Bubble” element on the page and follow the instruction in the editor.

Rob

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [July 19, 2021, 2:45pm UTC](https://forum.bubble.io/t/trigger-costum-event-within-javascript-code/150543/6 "2021-07-19T14:45:48Z")

</div>

Closed on July 19, 2021, 2:45pm UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
