/    Sign up×
Community /Pin to ProfileBookmark

Opening New Window, blocking the current window

Hi all,

We can open a new window through JavaScript using windows.open().

Can we block the original window from which this window was opened until we close the new window?

Thanks in advance

sanat

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@sridhar_423Jan 21.2006 — var newwin=window.open(url,"name","parameters");

1.put a time based function in your parent window using setInterval("some_function","time").This "setInterval" should be set only when you open the child window,

2. Pass a flag variable to your child window. for eg. flag=false;

3. use onbeforeunload in your child window and set the flag to true.

4. In the parent window check for this flag. If flag is false use "new.document.focus()" which will focus the document of the child window.
Copy linkTweet thisAlerts:
@sanatpadhyauthorJan 21.2006 — Hi Sridhar,

Thanks for the reply. Can you provide some code sample for this.
Copy linkTweet thisAlerts:
@sridhar_423Jan 21.2006 — Parent Window:

<body onfocus="chkCildWin()">

<input type=hidden name=flag value=false>

<input ... onclick="winopen()">

var newwin=null;

function winopen(){

newwin=window.open(url,ChildWindow,params);

}

function chkCildWin(){

if(newwin!=null){

if(document.formname.flag==false)

newwin.document.focus();

}

}
------------------------------------------------------


ChildWindow Page:

<body onbeforeunload="SetVal()">

function SetVal(){

window.opener.document.formname.flag=true;

}


------------------------------------------------------
×

Success!

Help @sanatpadhy 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 5.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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