James
James

Reputation: 49

link opening new window and refreshing current

I am using the following PHP line to create a link in a table to a new window

echo "<a href=\"InterfaceInfo.php?FXOrder=" . $row['FXOrder'] . "&TA5k=" . $TA5k . "&EfmGroup=" . urlencode($row['EfmGroup']) . "&EfmLink=no\" onclick=\"window.open(this.href, 'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=1,scrollbars=1')\"><center>1/" . $row['EfmGroup'] . "</center></a>";

This is working correctly for opening the new window. However, once the new window it loaded the current window with the link also opens the same link. What am I doing wrong with this?

Upvotes: 1

Views: 69

Answers (2)

Alex
Alex

Reputation: 7374

On the end of your link add ;return false;. This will prevent an action on the current window:

<a href=\"InterfaceInfo.php?FXOrder=" . $row['FXOrder'] . "&TA5k=" . $TA5k . "&EfmGroup=" . urlencode($row['EfmGroup']) . "&EfmLink=no\" onclick=\"window.open(this.href, 'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=1,scrollbars=1');return false;\">

Upvotes: 1

colburton
colburton

Reputation: 4715

The browser will navigate to whatever is set in href-attribute. If you do not want any action use href="javascript:void()" or less "valid" href="#".

Copy what you have currently in href to the window.open() instead of the this.href.

Upvotes: 1

Related Questions