/    Sign up×
Community /Pin to ProfileBookmark

differentiating pop up, pls help!!

i have a page that generate pop up when user click on a link….
the link will call javascript function and pass certain unique value of ‘userID’ to the function. what i am trying to do is to use this userID to differentiate name between one popup windows (childwindows) to another, so i can easily call the child window when needed. i need to detect whether the popup window for certain user has already exist or not….if no more exist, a new pop up window will be displayed whenever the user click on the link again. if the window exist, it just call the existing window to be focus, so there would not be redundant pop up for one user or one userID….
anydoubt pls tell me…thanks alot……

my email : [email][email protected][/email]

i have try the following code, but it keep prompting error :

<script language=”JavaScript”>

var popwindow_private = null;

function private_chat(parameter)
{
var userID = parameter;
// display the popup
var popwindow_privateChat = popwindow_private + userID;
if(popwindow_privateChat == userID)
{
popwindow_private = “Value”;
popwindow_privateChat = window.open(‘private_chat.php?recepientID=’ + userID, ‘_blank’,’width=650,height=450,resizable=no,toolbar=0,menubar=0,status=0,location=0,top=50,left=300′);

}
else
{
popwindow_privateChat.focus();
}
}

</script>

<a href= “javascript:void(0)” onClick=”private_chat($userID);”>Start to Chat<br></a>”;

if there is other way to do this pls let me know also…thnks again~~~

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Aug 31.2006 — Basic idea:

<i>
</i>var winPop = new Object;

function newWindow(id){
winPop[id] = window.open("foo");
}


Eric
Copy linkTweet thisAlerts:
@dethlonauthorSep 01.2006 — now..i have seen some people said using window.closed to detect wheter a window is closed or still open...

<script language="JavaScript">

var winPop = new Object;

function private_chat(id){

var userID = id;

winPop[id] = window.open('private_chat.php?recepientID=' + userID, '_blank','width=650,height=450,resizable=no,toolbar=0,menubar=0,status=0,location=0,top=50,left=300');

if(winPop[id].closed){

winPop[id] = window.open('private_chat.php?recepientID=' + userID, '_
blank','width=650,height=450,resizable=no,toolbar=0,menubar=0,status=0,location=0,top=50,left=300');

}

else{

winPop[id].focus();

}

}



</script>


i have tried the method, but i seem not working......the window.closed method cant even detect whether the windows exist or has been closed by user....

do anyone know how to effectively detect the existing windows???pls let me know!!!

thanks alot~~
Copy linkTweet thisAlerts:
@dethlonauthorSep 01.2006 — i have finally get it to work........

Thanks Aliens51....thanks again~~~


<script language="JavaScript">

var winPop = new Object;

function private_chat(id){

var userID = id;

if(!winPop[id]){

winPop[id] = window.open('private_chat.php?recepientID=' + userID, '_blank','width=650,height=450,resizable=no,toolbar=0,menubar=0,status=0,location=0,top=50,left=300');

}

else{

if(winPop[id].closed){

winPop[id] = window.open('private_chat.php?recepientID=' + userID, '_
blank','width=650,height=450,resizable=no,toolbar=0,menubar=0,status=0,location=0,top=50,left=300');

}

else{

winPop[id].focus();

}

}

}

</script>
×

Success!

Help @dethlon 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,
)...