Creating a popup window in a frame

adamssr
adamssr used Ask the Experts™
on
I start with a client-side image map located in a frame.  When I click on a hot spot, I wish to open a popup window in the same frame, without closing the frame.  I have used:

<AREA SHAPE="circle" coords="717, 53, 10" ALT="Name" href="link1.html" onClick="winOpen(this)">

to call the following function:

function winOpen(theLink) {
        linkWindow=window.open(theLink.href,'resizable=yes,width=190,height=135,status=no,location=no,toolbar=no,directories=no,menubar=no,scrollbars=yes');
}

Doesn't work.  What do I do?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Michel PlungjanIT Expert
Top Expert 2009

Commented:
<AREA SHAPE="circle" coords="717, 53, 10" ALT="Name" href="javascript:winOpen('link1.html')">

function winOpen(theUrl) {
                    linkWindow=window.open(theUrl,'resizable=yes,width=190,height=135,status=no,location=no,toolbar=no,directories=no,menubar=no,scrollbars=yes');

}

Netscape in particular does not like the onClick in area tags

Michel

Author

Commented:
Looks good, but when I tried it, I got an error message (invalid argument).
IT Expert
Top Expert 2009
Commented:
That is because your window.open is invalid - needs a window name, sorry I didn't spot that.

window.open(theUrl,'windowname','width=190,height=135,resizable,scrollbars')

Michel
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
Give him his points back. He forgot to wedge a name for the window between the URL and the attributes:

linkWindow=window.open(theUrl,someName,'resizable=....');
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Thanks mblase

Spotted it too  ;-)

Author

Commented:
Thanks, Michel.  Works fine.  Now, if I click on another hot spot on the image map, how can I make the new popup window replace the first?  I'll repost this second question with another 50 points for you if you can answer it.

Commented:
That's easy -- call winOpen() with a new URL. As long as it uses the same window name and parameters, it'll keep using the same popup window.

You may, however, want to add 'windowname.focus()' to your winOpen() function, to bring that window back to the front.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
or better, use
<BODY onLoad="if(window.focus) self.focus()">

in the new windows.

Michel

PS: Thanks for your enthusiasm, mblase...

Commented:
Hey, I like a race as much as anyone. :) (I'm not trying to steal anyone's points -- by all means, adamssr, give 'em to Michel.)

Now, Michel, you've been on here long enough this morning -- shouldn't you get back to work and let the rest of us earn some points? ;-)

Author

Commented:
Thanks again, Michel.  Works great.  Will post the new question as "For Michel".  Reply something and I'll give you the points.

Thanks also, mblase, but I like Michel's answer.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Hehe - save your points Adam...

I will go home, give mblase a few hours to stalk the questions ;-)

Michel

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial