We help IT Professionals succeed at work.

How do I check if a window is already open or give it focus using Flex/Flash

Joel_Sisko
Joel_Sisko asked
on
Dear Experts,

I have this code that will open the url as expected. The issue is that if I click the help button again that calls the fucntion, it opens a copy of the window that is already opened. How do I check that the window is already open and if so, give it focus?

Thanks.
private function PopWindow (HelpUrl:String): void {
	
	ExternalInterface.call('window.open', HelpUrl , '_blank','scrollbars=yes,resizable=no,width=400,height=400');
}

Open in new window

Comment
Watch Question

Michel PlungjanIT Expert
Top Expert 2009

Commented:
1. change
'_blank'
to something unique
2. put the focus in the onload of the page you load

Author

Commented:
Not sure how to do that; I should have stated earlier I am just a shade up from being a newbie.

Joel
IT Expert
Top Expert 2009
Commented:
<body onload="window.focus()">

or

<html>
<head>
<script type="text/javascript">
window.onload=function() { window.focus() }
</script>

in the html you popup

Author

Commented:
So if I use <body onload="window.focus()">, where would I put that into my code?

Joel
Michel PlungjanIT Expert
Top Expert 2009

Commented:
In the html of the page you load - HelpUrl