Closing a browser tab

Workarounds and usability notes.

Closing a browser tab

Postby John Robin Dove » Fri Feb 07, 2014 2:43 pm

Hi,

I found this javascript code here: http://raghunathgurjar.wordpress.com/20 ... avascript/ I pasted this bit:

{
var win = window.open("","_self"); /* url = "" or "about:blank"; target="_self" */
win.close();
}


into a field called "closeMe" and then used the exeJavascriptDirect() function with [commandString] text of field "closeMe" and ... it works! :D

I then tried to use an identical system in a second window that I open with subModal() and it doesn't work. :cry:

Any ideas please? It's not a big deal but I'd like to know why.

John
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Closing a browser tab

Postby Clifton » Fri Feb 07, 2014 3:13 pm

In order to close a window that is opened with subModal() you need to use either the X (in the title bar) OR call the the function setModalReturnVal(). The function setModalReturnVal() allows you to pass a user event back to the main window application while at the same time closing the window.

Also, it is good to know that subModal() opens a new window in a different way than the code that you pasted and executed with exeJavascriptDirect(). Popup blockers may prevent windows from opening in the case you cited, but the windows opened with subModal() will always be allowed and not detected as a popup.

Finally, take a look at pgGotoURL() as this is another window open method that is often used by PowerPac users to display additional content.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Closing a browser tab

Postby John Robin Dove » Sat Feb 08, 2014 6:30 am

Thanks Clifton,

Being pigheaded I had to find another way! I can close the submodal window with a button in the submodal window like this:

exeJavascriptDirect() [commandString] =

{
window.parent.hidePopWin();
}
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Closing a browser tab

Postby Clifton » Sat Feb 08, 2014 7:35 am

That string will indeed close the subModal() window. That function is internally called by the PowerPac when you use setModalReturnVal(). However, your string will not allow any data to be transferred back to the main window, which maybe doesn't matter in your particular application.

Have fun!
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron