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

Pop-up Window to separate URL

Status
Not open for further replies.

NoWayIsThisInUse

IS-IT--Management
Jul 16, 2002
79
0
0
US
I want to do something pretty simple, but am having a rough time with it.

I have a .gif file which I want to bring up a new window and direct it to a different url. I don't want to do this from a link (know how to do this already), or a submit button, but from an image.

I have javascript to pop-up the window and it works. The window name is "remote". Here's my code for the image:
<tr><td><nobr><a href=&quot; src=&quot;/content/PeopleNetLogo_Cignet_sm.gif&quot; onclick=&quot;popup()&quot; target=&quot;remote&quot; border=0 alt=&quot;TimeTracking&quot;></a></td></tr>

When I click on this, it pops up a blank window and then just changes my main window to the url 216.91.91.133.
I want my main window (my application) to stay and pop-up a separate window to the above url from the graphic.

Thanks in advance!
 
<button style=&quot;border: none; background: transparent;margin:0px&quot; onClick=&quot;myfunction();&quot;><img ...></button>


<script>
function myfunction()
{ myform.action = &quot;...url...&quot;;
myform.target = &quot;_blank&quot;;
myform.submit();
}
</script>
 
<BUTTON> isn't fully supported in all browsers. In my experience, it's more problem than it's worth, as nice as it is.

I think the problem you're having is, in your sample code, you're actually telling the browser conflicting commands.
Code:
<a href=&quot;[URL unfurl="true"]https://216.91.91.133/&quot;><img[/URL] src=&quot;/content/PeopleNetLogo_Cignet_sm.gif&quot; onclick=&quot;popup()&quot; target=&quot;remote&quot; border=0 alt=&quot;TimeTracking&quot;></a>
wraps an anchor around an image... so you're telling the browser &quot;when this anchor/image is clicked, go to this HREF.

But in the onclick of the img, you're saying call the function &quot;popup()&quot;... but not telling it what URL to open (presumably, since the ()'s of the function are empty).

And also in the img, you're setting the target to &quot;remote&quot;.


First, you don't need to use the onclick in the img tag... use it in the anchor, just like you're used to. This way, you have the opportunity to tell the anchor &quot;you know what, I'm going to call this javascript function, so you really don't need to follow the HREF afterall&quot;. You do this by adding &quot;return false&quot; to the event.
Code:
<head>

<script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;>
<!--
function popUp(url) { 
  window.open(url, 'popUp', 'scrollbars=no,status=no,resizable=no,width=300,height=300');
}
// -->
</script>

</head>

<body>
<A HREF=&quot;[URL unfurl="true"]http://www.yahoo.com/&quot;[/URL] onclick=&quot;popUp('[URL unfurl="true"]http://www.yahoo.com/');[/URL]
Code:
return false;
Code:
&quot;><IMG SRC=&quot;/images/myimage.gif&quot; border=&quot;0&quot; /></A>
</body>
will do it.

Or
Code:
<A HREF=&quot;[URL unfurl="true"]http://www.yahoo.com/&quot;[/URL] onclick=&quot;popUp('[URL unfurl="true"]http://www.yahoo.com/');return[/URL] false;&quot;
Code:
target=&quot;_blank&quot;
Code:
><IMG SRC=&quot;/images/myimage.gif&quot; border=&quot;0&quot; /></A>
will ensure that even people with javascript turned off will get a new window (though it won't be nicely sized and all).


The real question is why are you asking this in the ColdFusion forum ;-)





-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top