Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To Close or To Open, tis the Question... 2

Status
Not open for further replies.

sumilsay

Technical User
Feb 12, 2003
69
0
0
CA
hey peeps n freeks...

my dilemma...

i have a script that opens a pic in a new window when a link is clicked. you can close the window by clicking on the window itself. now... that's all fine and dandy, but what if the user doesn't close the window and wants to see another picture...

when another link is clicked, the picture window is now beneath the site window.

how can i make it so when the link is clicked, it either closes the previous window then opens another one, or it brings the window back to the front.

do you get it?

thanks for your time and help!

peace.

..::: code :::..

<!--open pic in new window BEGIN-->
<script language=&quot;JavaScript&quot;>
function openImage(images, w, h)
{
var windowprops = &quot;location=no,scrollbars=no,menubar=no,toolbar=no&quot; + &quot;,left=300,top=100&quot; + &quot;,width=&quot; + w + &quot;,height=&quot; + h + &quot;;&quot;

a = window.open(&quot;&quot;,&quot;popupimage&quot;,windowprops);
a.document.open();

a.document.write('<html><body topmargin=&quot;0&quot; leftmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>');

a.document.write(&quot;<a href='javascript:window.close()'><image src='&quot; + images + &quot;' width=&quot; + w + &quot; height=&quot; + h + &quot; border='0' alt=''></a>&quot;);

a.document.write('</body></html>');
a.document.close();
}
</script>

<!--open pic in new window END-->

<!-- link for picture -->
<a href=&quot;javascript:eek:penImage('pic.jpg',400,250)&quot;>Picture</a>
<!-- link for picture -->
 
You need to add a focus():

a = window.open(&quot;&quot;,&quot;popupimage&quot;,windowprops);
a.focus();
a.document.open();
 
me too. hahaha. thanks buddy guy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top