8
I have to open another tab with a link that is returned to from PHP to jQuery. I used window.open
but he asks to release the popup
and the client doesn’t like it at all. So I thought I’d do, when jQuery gets the link, it changes a <a href="javascript:void(0);" target="_blank"></a>
for <a href="http://www.LinkQueRetornou.com.br" target="_blank"></a>
and runs 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 action (DOM).
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');
$("a#linkredirect").trigger("click");
})
})
</script>
Like you were using with
window.open
? Here for me (in Chrome) your code opened normal in another tab withwindow.open
and_blank
. See on fiddle.– gustavox
Yes, mine also worked. But the client asked to allow popup. I think his was Safari
– Alisson Acioli