0

I have one strange issue as below for Chrome in iPad.

There is the web page, which call window.open and window.close to select the user and close. H/w when in 1st Tab page, it can successfully call window.open to open the page to select user, but when click select to call window.close, it does not work without any change, still stay at the current screen to select user.

But if I open the web page in 2nd, 3rd...Tab page, it can both successfully window.open and window.close to complete the user select process.

Meanwhile, if I clear all browsing data and close all tab pages, then the new 1st tab page will works with window.open and window.close.

But if I not only clear all browsing data, but also force close Chrome (double click home button and swipe Chrome out), then the new 1st tab page will fail with window.close.

Another interesting find is that if I open such as google.com at the 1st tab of Chrome, then in 2nd tab still open my web and call window.open and window.close, all of them also works.

May I know if there is any difference about the 1st tab of Chrome or something else wrong with window.close for Chrome in iPad.

Finally I find possibly issue root as opener is null at the 1st tab.

Could you pls help to check and thx a lot!

    function doSelect( userid, username )
        {
            opener.document.`formName`.`fieldPrefix`_ID.value = userid;
            opener.document.`formName`.`fieldPrefix`_Name.value = username;

            if ( opener.document.`formName`.`fieldPrefix`_SavedName )
            {
                opener.document.`formName`.`fieldPrefix`_SavedName.value = username;
            }

            if ( opener.markDirty != null )
            {
                opener.markDirty();
            }

            window.close();
        }

     function chooseUser( prefix, title, filter ){
         window.open("/livelink/livelink.exe?func=user.SelectUserDlg&formname=ReportPrompts&fieldprefix=" + prefix + "&title=" + title + filter + "&DisplayUserName","","height=340,width=680,scrollbars=yes,resizable=yes,menubar=no")
zhususui
  • 25
  • 4
  • possible duplicate of [window.close and self.close do not close the window in Chrome](http://stackoverflow.com/questions/19761241/window-close-and-self-close-do-not-close-the-window-in-chrome) – ceejayoz Oct 31 '14 at 14:42

1 Answers1

0

Because of abuse in the early days of JavaScript, browsers will only let you window.close() a window that you created via JavaScript or a brand new window.

http://www.w3.org/TR/html51/browsers.html#dom-window-close

The close() method on Window objects should, if all the following conditions are met, close the browsing context A:

  • The corresponding browsing context A is script-closable.
  • The responsible browsing context specified by the incumbent settings object is familiar with the browsing context A.
  • The responsible browsing context specified by the incumbent settings object is allowed to navigate the browsing context A.

A browsing context is script-closable if it is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), or if it is a top-level browsing context whose session history contains only one Document.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368