Forum Moderators: open

Message Too Old, No Replies

Button image = popup. How?

         

BrianH

6:05 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



Hello all;

I'm try to open a new popup window when clicking on a
button image(gif,jpg,png,etc)

Button Code:
<p align="center">
<img border="0" src="images/DemoButton.jpg" width="89" height="37">
</p>

Now, for a popup, I've got this, which works quite
nicely for some other things.
Popup Code:
<script>
var PopUpX = (screen.width/2)-285;
var PopUpY = (screen.height/2)-210;
var pos = "left="+PopUpX+",top="+PopUpY;

function PopUp(){PopUpWindow = window.open("http://xxx/yyy/xxx.htm","DEMO","width=570,height=420,"+pos);}
</script>

<a href="javascript:PopUp()">DEMO</a>

What I am having a problem with is linking the two together. I'd like the image file to perform the script
instead of the <a href...> text link.

I think I'm missing something simple, but can't seem
to see it...

garann

6:10 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



I think if you put that same link around your image, you'll have it:

<a href="javascript:PopUp()"><img border="0" src="images/DemoButton.jpg" width="89" height="37"></a>

And Welcome to Webmaster World. :)

BrianH

6:14 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



Ok, I'm now using an area image map to invoke the java
function. Seems to work ok except for the new window
title bar.

<p align="center">
<map name="FPMap4">
<area href="javascript:PopUp()" shape="rect" coords="8, 5, 79, 29">
</map>
<img border="0" src="images/Button.jpg" width="89" height="37" usemap="#FPMap4">
</p>

Other ideas/input still welcome.....

BrianH

6:25 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



garann;

Thanks! I knew I was missing the tree for the forest.

I saw your post after my last one about the image map.

Both work, but I prefer the smallest code possible so
your post is perfect.

Now, to make sure the focus is correct and stop them
from minimizing and moving it around :)

Thanks again!

korkus2000

6:26 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure I understand, http://xxx/yyy/xxx.htm controls the title of the new window.

BrianH

6:38 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



korkus2000;

Thanks for pointing that out. That is indeed what I was
referring to. I thought there might be an attribute in
window.open() that controlled that.

korkus2000

6:41 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld BrianH :)