Hillas
asked on
Closing a browser window from Flash
How do I close a pop-up window with a specific name from a button click in the parent window. Thnaks for the help.
In the HTML where also the Flash object is put you can place the following Javascript:
<script language="JavaScript">
<!--
function openwin()
{
myWindow = window.open('test.html','w inname','w idth=190,h eight=210' );
}
function closewin()
{
myWindow.close();
}
// -->
</script>
--------
With the above Javascript you assign the name 'myWindow' to the opened window. This way you can use this name to control the object (also move it, etc).
With the function closewin() you then close the window 'myWindow'.
If you have more windows, just give them different names.
In flash the following actionscript would be used:
on (release) {
getURL ("javascript:openwin();");
}
To open the window.
on (release) {
getURL ("javascript:closewin();") ;
}
To close the window again.
Hope this helps!
<script language="JavaScript">
<!--
function openwin()
{
myWindow = window.open('test.html','w
}
function closewin()
{
myWindow.close();
}
// -->
</script>
--------
With the above Javascript you assign the name 'myWindow' to the opened window. This way you can use this name to control the object (also move it, etc).
With the function closewin() you then close the window 'myWindow'.
If you have more windows, just give them different names.
In flash the following actionscript would be used:
on (release) {
getURL ("javascript:openwin();");
}
To open the window.
on (release) {
getURL ("javascript:closewin();")
}
To close the window again.
Hope this helps!
oeps posted my answer just too late, did not see the answer from rootdir... sorry
ASKER
Thanks for the help rootdir.
I need some clarification if you don't mind.
Below is the JavaScript that I am using to open and close pop-up windows. Unfortunately, this only closes the most recently opened window. I can't seem to get it to close a specific window (a window called "Images" for instance.)
<SCRIPT LANGUAGE=JavaScript>
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLt oOpen, windowName, windowFeatures);
}
function closewin()
{
newWindow.close();
}
</SCRIPT>
Thanks again.
I need some clarification if you don't mind.
Below is the JavaScript that I am using to open and close pop-up windows. Unfortunately, this only closes the most recently opened window. I can't seem to get it to close a specific window (a window called "Images" for instance.)
<SCRIPT LANGUAGE=JavaScript>
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLt
}
function closewin()
{
newWindow.close();
}
</SCRIPT>
Thanks again.
ASKER
Thanks as well dutchfoxer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this javascript function will be there in your parent window head.
<SCRIPT LANGUAGE="JavaScript">
var newwin;
function launchwin(winurl,winname,w
{
newwin = window.open(winurl,winname
if(javascript_version > 1.0)
{
setTimeout('newwin.focus()
}
}
// add this function to close newly popup window from parent or flash
function closewin()
{
if (!newwin.closed)
newwin.close();
}
</SCRIPT>
Call closewin function from flash button like this
on (press, release) {
getURL("javascript:closewi
}
If you have multiple popups then Fill array with unique instace name for each popup. And pass that unique id to closewin function.
This will help you lot. I have created sample for you, If you want post your email
Cheers
RootDir