Aleksandar Djordjević Aleksandar Djordjević - 1 year ago 65
HTML Question

Javascript alert for deleting mysql data opens in new tab

I need to add JS alert for deleting certain records from mysql. Simple on... Sure you want to delete? Yes - leads to page to delete, No - does nothing. Problem is whenever i click on Yes it opens a new tab which i don't need (want all in current tab). Any solutions?


function confirmDelete(url) {
var aa =;
if (confirm("Sure to delete: "+ aa +"?")) {'/www/site/m_delete.php?id=' + aa +'');
} else {
return false;



<a class="box_setting fa fa-ban" style="cursor:pointer;" id="'.$id.'" onClick="confirmDelete(\'/www/site/m_delete.php?id='.$id.'\')"></a>

Answer Source

For opening the page in same tab use this code:-'/www/site/m_delete.php?id=' + aa +'', '_self'); // _self refers to window/tab that the code is currently running
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download