简体   繁体   中英

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?

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 .

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;\\">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM