ATTR passing _blank

3

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

Could someone tell me where I'm going wrong? Thanks 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");
}); 

    
asked by anonymous 28.12.2018 / 03:41

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 #veranexo element. Changing location.href only changes the current tab page, you can not apply a target to this property.

    
28.12.2018 / 03:54