window.open, target=_blank opens two windows

D

DonD

The code:
<a href="/art/visit/openhouse03/images/17.jpg" target="_blank"
onclick="popCenter(this.href,'name','500','500','no'); return false;">
<img src="/art/visit/openhouse03/images/thumb17.jpg"></a>

The problem:
I always get two windows. I have the required "return false". I found a
post (http://tinyurl.com/avjlh) that addresses my exact problem, but
they told the guy he wasn't returning false properly. That doesn't make
any sense.

I could hack it by targeting the same window that JS opens, but then
I'm loading the page twice.

I just want it call my function if the user has JS, and open a blank
window if they don't.

Thanks.

--Don D.
(not the same Don as in the link given above)
 
R

RobG

DonD said:
The code:
<a href="/art/visit/openhouse03/images/17.jpg" target="_blank"
onclick="popCenter(this.href,'name','500','500','no'); return false;">
<img src="/art/visit/openhouse03/images/thumb17.jpg"></a>

The problem:
I always get two windows. I have the required "return false". I found a
post (http://tinyurl.com/avjlh) that addresses my exact problem, but
they told the guy he wasn't returning false properly. That doesn't make
any sense.

I could hack it by targeting the same window that JS opens, but then
I'm loading the page twice.

I just want it call my function if the user has JS, and open a blank
window if they don't.

I suspect something funny is happening in your popCenter() script. Try
the following:

<script type="text/javascript">
function popCenter( url, n, a, b, c ){
aWin = window.open( url, n, '');
}
</script>

<a href="a.gif" target="_blank" onclick="
popCenter(this.href,'name','500','500','no'); return false;
"><img src="a.gif"></a>


I can only test in IE with JavaScript on, but it worked fine in Firefox
with scripting on or off.
 
P

Phat G5 (G3)

The code:
<a href="/art/visit/openhouse03/images/17.jpg" target="_blank"
onclick="popCenter(this.href,'name','500','500','no'); return false;">
<img src="/art/visit/openhouse03/images/thumb17.jpg"></a>

The problem:
I always get two windows. I have the required "return false". I found a
post (http://tinyurl.com/avjlh) that addresses my exact problem, but
they told the guy he wasn't returning false properly. That doesn't make
any sense.

I could hack it by targeting the same window that JS opens, but then
I'm loading the page twice.

I just want it call my function if the user has JS, and open a blank
window if they don't.

Thanks.

--Don D.
(not the same Don as in the link given above)
Don, get rid of the target="_blank" that is not needed. The javascript
function is separate of the html function target and that is why you are
seeing that happening.
 
D

DonD

Phat G5(G3),

I'm not sure I understand. If the user has JS turned off, I still want
them to get a new window. I don't want the larger image to load in the
same window. If the user does have JS, then they get my window with the
proper sizing, etc. I can't give non-JS users a new window without
target=_blank, can I? I don't know a way.

--Don D.
 
K

Kevin Newman

?? said:
Then why dun u just leave the JS and use HTML on its own.


Because you can customize the popup in javascript in a way that you
cannot in html. Doing it this way means it will "gracefully degrade" if
javascript is turned off, but that you will get all the benefits if it
is on.

Kevin N.
 
D

DonD

RobG,

You're exactly right. I was calling another function within popCenter
and it was opening the additional window. I was digging in the wrong
place. Thanks!

--Don D.
 
P

Phat G5 (G3)

Phat G5(G3),

I'm not sure I understand. If the user has JS turned off, I still want
them to get a new window. I don't want the larger image to load in the
same window. If the user does have JS, then they get my window with the
proper sizing, etc. I can't give non-JS users a new window without
target=_blank, can I? I don't know a way.

--Don D.
No, you cannot. Its one way or the other. The only thing I can think of is
to write a function that will loop thru all windows looking for one with
your url and if not found then pop a new one. It'd take some work but
doable.

-Steffan
 
P

Phat G5 (G3)

Then why dun u just leave the JS and use HTML on its own.


mo
Earlier in this thread he is using a JS function to pop the window centered
and sized.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top