ATTR passing _Blank

Asked

Viewed 31 times

2

The code below redirects to another page, but I would like it to be in another browser tab, so I used _Blank. but it does not go to another tab.

Could someone tell me where I’m going wrong? Thank you guys.

<script type="text/javascript">  
$('#veranexo').click(function(){       
   var ass_id = $("#ass_id").val();
   $(location).attr('href','<?php echo base_url() ?>/dashboard/usuarios/excluir/'+ass_id);
   $(location).attr("target","_blank");
}); 

1 answer

1


Instead of using location, use window.open:

$('#veranexo').click(function(){
   var ass_id = $("#ass_id").val();
   window.open(
     '<?php echo base_url() ?>/dashboard/usuarios/excluir/'+ass_id,
     '_blank'
   );
});

Will open the URL in a new tab by clicking on the element #veranexo. Change the location.href just change the page of the current tab, there is no way to apply a target on that property.

  • Immoral. Thanks a lot, man. It worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.