2427
Views
16
Comments
How to close a browser window or tab
Discussion
I have a page with a list of cases, the user clicks in one and opens this case in a new tab.

I want for the user to be able to click on a button to close this new tab, instead of just clickin on the "x" in the browser tab (I want to be able to save the case before exiting)

I saw this javascript...

window.open('','_self').close()

But how do I implement that in a button action?

Thanks!

2014-02-13 10-06-38
Ricardo Silva
You can either use an ajax with the RunJavascript RichWidgets action for that code, or a Navigate button with "javascript:your_code" as the target.
2016-05-21 22-40-27
Macro101
Sorry, but being a newbie I could not figure out how to perform either of those ideas:

1) I cannot find any "RunJavascript" RichWidget and even if I did, I would not know how/where to place it.

2) I can't type code in the "destination" box for the navigation button. All I can do is to choose a target screen or action.

Can you give me an example how to perform any one of those two solutions?

Thanks.
2019-11-12 17-31-26
Justin James
 
MVP
1. You need to make sure that you have a reference to it, it's in the Rich Widgets eSpace. It is an action (to be used in logic) not a widget (to be dropped on a screen).

2. Change the "Destination" to "ExternalURL" in the list, then give it the JavaScript as the URL. If your eSpace doesn't have "ExternalURL" available, go to your common widget area, right-click, choose "External Site" to create it, then right-click and add a dynamic URL parameter.

J.Ja
2016-05-21 22-40-27
Macro101
Thanks!
2024-10-25 09-14-42
Christopher Bautista

Macro101 wrote:

I have a page with a list of cases, the user clicks in one and opens this case in a new tab.

I want for the user to be able to click on a button to close this new tab, instead of just clickin on the "x" in the browser tab (I want to be able to save the case before exiting)

I saw this javascript...

window.open('','_self').close()

But how do I implement that in a button action?

Thanks!

Hi Macro,

How did you implemented this using the RunJavaScript Action?

Thank you and kind regards,

Christopher


2019-09-30 07-35-56
Aurelio Junior

Hi Christopher,

Change your button's "Method" property to "Ajax Submit" and, on its click action, call the "RunJavaScript" action as pictured below:

2017-07-06 09-31-00
Jasper Oudenaarden

Hi Christopher,

Add the RunJavaScript extension as a dependency to your module and then add the following javascript to the action (closing button/link) in the screen you're want to close:

window.close();

Looks like this:

Hope this helps ;)

Regards,

Jasper

2024-10-25 09-14-42
Christopher Bautista

Thanks guys for the quick response.

I plan to invoke it in the preparation just in case I detect a duplicate of the URL being used.

Will it still work?

Currently, I'm testing it but it seems not working.

Can it be used in the Preparation stage?

Thank and regards,

Christopher

2016-04-21 20-09-55
J.
 
MVP

Ah,

that's a different requirement all together.


2024-10-25 09-14-42
Christopher Bautista

Hi J,

Do you have a suggestion?

Or have read a previous post similar to it?

Thanks and regards,

Christopher

2017-07-06 09-31-00
Jasper Oudenaarden

I don't think this will work because this is typically a frontend feature.......preparation is data/backend related and therefor not a logical place to do these kind of things.

2016-04-21 20-09-55
J.
 
MVP

Hi,


I don't think you can catch it in the preparation, 

Using Javascript assign a unique id like a guid to the browser window / tab by assigning the guid value to the window.name property. window.name property is unique to each browser window/tab and won't be shared across the windows.

from there you will need to keep track of the guid and session and your activeId...


tbh, it's rather much work and you better solve it by chekcing it when inserting/updating it to the database with versioning for example.


2019-11-12 17-31-26
Justin James
 
MVP

I'm with J... this is sounding worse and worse. This is a bad approach to the issue.

J.Ja

2024-10-25 09-14-42
Christopher Bautista

Thanks for the advise guys.

What I did instead is redirection to a Web Screen, informing the user that reusing the same URL is not allowed.

Thank you and kind regards,

Christopher

2024-09-20 14-44-46
Shivani Desai

I want to display a modal widget on a screen and than modal should get closed when i click enewhere on screen .

How can i implement it.please help

Thanks and Regards!

2014-10-21 20-15-17
Alberto Ferreira

Hello Shivani

I propose you open a new discussion with your question.

Usually we didn't follow very old discussions.


Regards  

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.