/    Sign up×
Community /Pin to ProfileBookmark

opened window is null

Hi everyone,

I have an issue with a forgotten window.

I spawn the window in one page, then opener switches to another page. When that occures, if i check window handle if it is null, it is null, even though I have it still opened.

I have declared this window in the javascript file on top as var window_handler and then in function in that javascript I have something like window_handler = window.open(….);

now when the opener changes the url, i use the same javascript file and in that file i have something like if(window_handler == null){ alert(‘windows is null’)}

so the question is, is there a way to declare the window_handle as a global variable for that particular website, or is there a way to loop all open browser windows and check the title or some other property of the window that can show me which window is that?

cheers

s.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinMar 14.2007 — okay, if you think it is global, you are right up to a point.

it is global till you leave that page.

the problem is that once you leave the url, you leave the script that opened the window, and so window.opener is no longer valid and the open window is simply floating there with no parent.

you are missing an important concept here.

if A is the opener of B and A no longer exists, how can you reference B?

it matters not if A creates C unless B is assigned to C before A is destroyed.

if C becomes A, then A is only the reference of C, not the opener, and so it is not an object but simply a reference, and therefore has no properties other than a string.

Think about that and if you are still stuck PM me.

Just look at the situation and try to figure out what you need to do.

//erlin!
×

Success!

Help @salispahic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...