Redirect to a new tab | XM Community
Skip to main content
Question

Redirect to a new tab

  • December 11, 2023
  • 2 replies
  • 210 views

jmborzick
QPN Level 5 ●●●●●
Forum|alt.badge.img+41
  • QPN Level 5 ●●●●●
  • 261 replies

I have an end of survey block that redirects the users to a new URL. I would  like that new url to open in a new tab. Is that possible? 

 

As a workaround, I tried using the advice of a different post and insert JavaScript into an end of survey message, but the below script isn’t redirecting the user. 

 

<script>

setTimeout(function() { window.open("https://www.wikipedia.org", "_blank");

}, 1000);

 

</script>

2 replies

ArunDubey
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+41
  • QPN Level 8 ●●●●●●●●
  • 589 replies
  • December 12, 2023

Did you try to save link under HTML like this.

<a class="myLink" href="https://www.wikipedia.org" target="_blank"> CLICK HERE NOW </a>

then click .myLink

<script type="text/javascript">
$(function(){
$('.myLink').trigger('click');
});
</script>



OR



<script type="text/javascript">
$(function(){
window.location.href = $('.myLink').attr('href');
});
</script>

 


jmborzick
QPN Level 5 ●●●●●
Forum|alt.badge.img+41
  • Author
  • QPN Level 5 ●●●●●
  • 261 replies
  • December 12, 2023

@ArunDubey Thank you for your reply. The problem that I’m having is that I want an automatic redirect in a new tab. Both of your options successfully open the link in a new tab, but I would like them to be redirected automatically to a new tab.