Close site ❎

Is there a way to close the website in a WF? I can’t find it in the navigation WF.

1 Like

By close the website do you mean close the active browser window or navigate away to another external site?

I want to close the active browser window

You could do something like:

<script>window.close();</script>

in a separate page which the user is navigated to.

Maybe even an HTML element if you use the onclick tag.

1 Like

Would that work for any browser?

It’s a simple JavaScript method; it’d be surprising to see it not supported for popular browsers.

http://www.w3schools.com/jsref/met_win_close.asp

1 Like

If I recall correctly, it triggers an alert saying that the site is trying to close the page or something like that.

Actually, you’re referring to a play on the window.confirm() method behavior. :slight_smile:

window.close() - https://bubble.io/page?type=page&name=window_close&id=forumapp3&tab=tabs-1

1 Like

No, it depends the context under which the window was opened…

Refer to this SO summary of the .close() W3 specification;

There are circumstances where .close() will trigger a prompt for security reasons.

So, @romanmg, no it’s flaky! depends on context.

@thomas.schijf have a look at the link I provided, it gives workaround etc, if you run into problems.

2 Likes

It’s worth clarifying that this method will only close the tab in Chrome.

Thanks for the share. Good for reference!

3 Likes

you look this code
window.close()
you want to close this tab.

That is what was mentioned in the thread earlier, but it comes with some constraints depending on the browser and the context under which the window was opened.

The developer needs to be aware of the issues that can arise using this approach.

This method doesn’t appear to be working in Chrome anymore.

Any other methods to close a tab?