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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open popup in the same popup. 2

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Dear All,

I have a Javascript function that basically opens an image in a popup window the same size as the image. Here is the Javascript code:-

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>

And then to open the images I use this code:-

<map name=&quot;Map&quot;>
<area shape=&quot;rect&quot; coords=&quot;37,14,118,56&quot; href=&quot;#&quot; onMouseUp=&quot;MM_openBrWindow('homepop1.html','','width=320,height=240')&quot;>
<area shape=&quot;rect&quot; coords=&quot;126,14,197,58&quot; href=&quot;#&quot; onMouseUp=&quot;MM_openBrWindow('homepop2.html','','width=320,height=240')&quot;>
<area shape=&quot;rect&quot; coords=&quot;209,13,283,66&quot; href=&quot;#&quot; onMouseUp=&quot;MM_openBrWindow('homepop3.html','','width=320,height=240')&quot;>
</map>

However, if the user does not close the popup window, three popup windows open up with the three images.

Is there a way on how I can display the images in the same popup, so that instead of 3 popup windows I have only 1?

Thanks for your help and time
 
TRY

function MM_openBrWindow(theURL,winName,features) { //v2.0
if(!winName){
window.open(theURL,winName,features);
}else{
winName.location.href = theURL
// or
// top.winName.location.href = theURL
}}



 
Use the second parameter as simon told you.
That's the window name, using same name there will open in same window. i'm using popup as a name.
Code:
             <map name=&quot;Map&quot;>
                <area shape=&quot;rect&quot; coords=&quot;37,14,118,56&quot; href=&quot;#&quot; onMouseUp=&quot;MM_openBrWindow('homepop1.html','popup','width=320,height=240')&quot;>
                <area shape=&quot;rect&quot; coords=&quot;126,14,197,58&quot; href=&quot;#&quot; onMouseUp=&quot;MM_openBrWindow('homepop2.html','popup','width=320,height=240')&quot;>
                <area shape=&quot;rect&quot; coords=&quot;209,13,283,66&quot; href=&quot;#&quot; onMouseUp=&quot;MM_openBrWindow('homepop3.html','popup','width=320,height=240')&quot;>
              </map>

________
George, M
 
I tried this code but it is still opening multiple popups!
 
Now I have got an error shaddow using your code:-

'location' is null or not an object.
 
Yes cuz winName parameter it's an string and not the actuall window name.
Try this function then.
Code:
function MM_openBrWindow(theURL,winName,features) { //v2.0
if(winName){
  window.open(theURL,winName,features);
}else{
  winName.location.href = theURL
}}

________
George, M
 
Yes it worked now thanks Shadow.

&quot;Yes cuz winName parameter it's an string and not the actuall window name.&quot; --- Can you please explain this to me shadow cause I am not really into Javascript.

Another thing, how can I set the windows to focus? Cause at the moment, after clicking the image on the main page, i have to maximize it to see it.

Thanks for all your help.
 
&quot;Yes cuz winName parameter it's an string and not the actuall window name.&quot;
This is the window.open sintax

windowref it's the reference to the new opened window

url it's the page url

windowname it's the window name wich you could access the
opened window, it's actually the original name of the variable wich stores the window reference. windowref should be same thing as windowname

parameter it's the opened window settings


windowref=window.open(url,windowname,parameters)

I hope i explained ok, i'm not good at english explanations yet :)
As for the focus use another version :)
Code:
function MM_openBrWindow(theURL,winName,features) { //v2.0
if(winName){
  window.open(theURL,winName,features);
}else{
  winName.location.href = theURL
}
winName.focus()
}


________
George, M
 
ok I got your explanation.

But now, with the new code, I got an error before opeining the popup:-

Object doesn't support this property or method
 
Yes, i hate keep forgoting things:)
Now if this isnt working... i'm gonna take a break :)
Code:
function MM_openBrWindow(theURL,winName,features)
{
  var tmpWin=window.open(theURL,winName,features);
  tmpWin.focus()
}


________
George, M
 
No break for me then :(
And thanks for the star.

________
George, M
 
Your' welcomed mate, its the least I could have done eh!

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top