Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Closing a child popup from itself



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
rafiquea



Joined: 06 Mar 2008
Posts: 2

PostPosted: Thu Mar 06, 2008 5:20 pm    Post subject: Closing a child popup from itself Reply with quote

I have the following scripts (I've cut them down) & I guess this will be really easy for someone. The scripts open/close the child popup from the main window (test.html) but I want to close the child popup from itself (test2.html). You will see what I have attempted to no avail. Help appreciated. Crying or Very sad

TEST.HTML - FILE 1
-------------
<HEAD>

<SCRIPT LANGUAGE="JavaScript">


function move_box(an, box) {
var cleft = 10;
var ctop = 10;
var obj = an;
//while (obj.offsetParent) {
// cleft += obj.offsetLeft;
// ctop += obj.offsetTop;
// obj = obj.offsetParent;
//}
box.style.left = cleft + 'px';
ctop += an.offsetHeight + 8;
if (document.body.currentStyle &&
document.body.currentStyle['marginTop']) {
ctop += parseInt(
document.body.currentStyle['marginTop']);
}
box.style.top = ctop + 'px';
}

function show_hide_box(an, width, height, borderStyle) {
var href = an.href;
var boxdiv = document.getElementById(href);
if (boxdiv != null) {
if (boxdiv.style.display=='none') {
move_box(an, boxdiv);
boxdiv.style.display='block';
} else
boxdiv.style.display='none';
return false;
}

boxdiv = document.createElement('div');
boxdiv.setAttribute('id', href);
boxdiv.style.display = 'block';
boxdiv.style.position = 'absolute';
boxdiv.style.width = width + 'px';
boxdiv.style.height = height + 'px';
boxdiv.style.border = borderStyle;
boxdiv.style.backgroundColor = '#fff';

var contents = document.createElement('iframe');
contents.scrolling = 'no';
contents.frameBorder = '0';
contents.style.width = width + 'px';
contents.style.height = height + 'px';
contents.src = href;

boxdiv.appendChild(contents);
document.body.appendChild(boxdiv);
move_box(an, boxdiv);

return false;
}
</SCRIPT>
</HEAD>



<BODY>
<A HREF="test2.html" onClick="return show_hide_box(this,450,370,'2px dotted')" >
CLIK HERE TO OPEN/CLOSE WINDOW
</BODY>

</HTML>

TEST2.HTML - FILE 2
--------------
<HTML>
<HEAD>

<SCRIPT>
function show_hide_boxx(an)
{
var href = document.an;
var boxdiv = an.getElementById(href);
boxdiv.style.display='none';
return false;
}
</SCRIPT>


</HEAD>

<BODY>
<TABLE border="0" WIDTH="100%">
<TR>
<TD WIDTH="10%">
</TD>
<TD>
<h2><center>Help Screen</center></h2>
</TD>
<TD WIDTH="10%" ALIGN="right" VALIGN="TOP">
<font color="red"><B>
<A href="javascript:show_hide_boxx(this);">
[CLICK TO CLOSE TRY 1]
</A>
<A href="javascript:self.close()">
[CLICK TO CLOSE TRY 2]
</A>
</B>
</FONT>
</TD>
</TR>
</TABLE>

</BODY>
</HTML>
Back to top
View user's profile Send private message
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 259
Location: Cebu City Philippines

PostPosted: Fri Mar 07, 2008 3:15 am    Post subject: Re: Closing a child popup from itself Reply with quote

I suppose it's not <a href="javascript:self.close()">[CLICK TO CLOSE TRY 2]</a>

...but <a href="javascript:window.close()">[CLICK TO CLOSE TRY 2]</a>

See if it helps Very Happy
Back to top
View user's profile Send private message Yahoo Messenger
rafiquea



Joined: 06 Mar 2008
Posts: 2

PostPosted: Fri Mar 07, 2008 11:22 am    Post subject: Re: Closing a child popup from itself Reply with quote

Thank you for that idea but I have tried that and it makes no difference. Any other thoughts please.....
Back to top
View user's profile Send private message
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 259
Location: Cebu City Philippines

PostPosted: Sat Mar 08, 2008 6:12 am    Post subject: Re: Closing a child popup from itself Reply with quote

Try changing your test2.html to:
Code:

<A href="show_hide_boxx(this);">
[CLICK TO CLOSE TRY 1]
</A>
<A href="window.close()">
[CLICK TO CLOSE TRY 2]
</A>


I got it working, but i'm not certain if this was really what you wanted.
See if it helps Rolling Eyes
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap