Page 1 of 1

Closing a browser tab

PostPosted: Fri Feb 07, 2014 2:43 pm
by John Robin Dove
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

Re: Closing a browser tab

PostPosted: Fri Feb 07, 2014 3:13 pm
by Clifton
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.

Re: Closing a browser tab

PostPosted: Sat Feb 08, 2014 6:30 am
by John Robin Dove
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();
}

Re: Closing a browser tab

PostPosted: Sat Feb 08, 2014 7:35 am
by Clifton
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!