I have to open another tab with a link that is returnable from PHP to jQuery. I've used window.open
but it asks to release popup
and the client does not like it at all. So I thought of doing, when jQuery receives the link, it changes <a href="javascript:void(0);" target="_blank"></a>
to <a href="http://www.LinkQueRetornou.com.br" target="_blank"></a>
and performs a function to simulate a click to open in another tab. The problem is that I made the code below and it is not working because it does not open the page in another tab, now I do not know if it is because the link was added later in a jQuery (DOM) action.
HTML + jQuery
<button class="button" type="button" id="teste">Click</button>
<a href="javascript:void(0);" id="linkredirect" target="_blank"></a>
<script>
$(document).ready(function(){
$("#teste").click(function(){
$("a#linkredirect").prop('href', 'http://www.google.com.br');
$("a#linkredirect").trigger("click");
})
})
</script>