| |

VerySource

 Forgot password?
 Register
Search
View: 2132|Reply: 10

A frame page, how to determine whether window.parent.opener is closed? ?

[Copy link]

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-14 10:30:01
| Show all posts |Read mode
How to determine whether window.parent.opener is closed. Window.parent.opener is closed. When taken out with js, window.parent.opener is not equal to null.
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-13 21:00:02
| Show all posts
if (window.parent.opener) {
     Did not close
} else {
     It has been closed
}
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-13 21:30:01
| Show all posts
if (window.parent.opener) {
    Did not close
} else {
    It has been closed
}
Reply

Use magic Report

0

Threads

29

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-4-15 17:30:01
| Show all posts
Should it be if (window.parent.opener.close ())? Never used, haha
Or is it window.parent.opener = "undefine"? It feels unreasonable
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-6 21:45:02
| Show all posts
window.parent.opener.closed? "Closed": "Not closed"
Reply

Use magic Report

0

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-7 01:45:01
| Show all posts
var 7660367 = window.parent.opener;

if (typeof (7660367)! = "undefined"&&! 7660367.closed)
{
    ; //
}
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-6-24 22:00:01
| Show all posts
function shutwin()
{
     var wp = window.parent.opener;
        if(wp!=null&&typeof(wp) != "undefined"&&!wp.closed)
        {
            if (wp.document.forms[0].txtRefreshParent != null)
            {
                wp.document.forms[0].txtRefreshParent.value="Refresh";
            }
            else
            {
               if(wp.document.forms[0].ctl00_MainPlaceHolder_txtRefreshParent!=null)
               {
                   wp.document.forms[0].ctl00_MainPlaceHolder_txtRefreshParent.value="Refresh";
               }
            }
            wp.document.forms[0].submit();
        }
    window.parent.close();
}
In fact, wp is closed, but why is wp.closed equal to true, and typeof(wp)="object", why? ? ?
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-31 13:30:01
| Show all posts
In fact, wp has been closed, but why is wp.closed equal to true, and typeof(wp)="object", why? ? ?
It seems that I have already practiced Hug, and the above results are understandable. I just throw the bricks indiscriminately and the master will continue.
wp = window.parent.opener;
WP is a reference to a window. Generally, if the window is closed, the window itself has been destroyed, and in principle the corresponding object does not exist. But this is only in the case of a single page.
And here the child page of wp still exists, so the window object of the child page still exists, and this window object also saves the reference to wp (ie window.parent.opener), although in the environment object of wp, it has already It is undefined, but window.parent.opener still exists in the child page. It should be a null object (maybe not null), so wp.closed is true.
The explanation is a bit far-fetched.
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-8-1 22:15:01
| Show all posts
The problem has been resolved, the solution is as follows:
function shutwin()
{
    try
    {
         var wp = window.parent.opener;
            if(wp!=null)
            {
                window.parent.close();
                if (wp.document.forms[0].txtRefreshParent != null)
                {
                    wp.document.forms[0].txtRefreshParent.value="Refresh";
                }
                else
                {
                   if(wp.document.forms[0].ctl00_MainPlaceHolder_txtRefreshParent!=null)
                   {
                       wp.document.forms[0].ctl00_MainPlaceHolder_txtRefreshParent.value="Refresh";
                   }
                }
                   wp.document.forms[0].submit();
            }
            
    }
    catch (exc)
        {
            if (exc.number == -2146828218)//Exception: "No permission"
            {
                return;
            }
            else
            {
                throw exc;
            }
        }
}
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-8-1 22:30:01
| Show all posts
I looked at the exception in detail, and finally found this solution, which has been successfully solved with this solution.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list