Closing a Tab or a Pop Up Window | XM Community
Skip to main content
Hi Everyone,



In my survey, to provide participants with additional information, I have three links in a page which open related information in a new tab. However, I also want these tabs to close when participants click on the next button. Is there a way to achieve this with Javascript or Html. I am also collecting information on whether they click the link or not (which I was able to solve by using HTML and javascript and I can post the code if needed).

Thank you!

Hi there, if you still need, I was able to put this in place by following the advice in this thread.
I adapted their example and created divs in the HTML that are styled to look like hyperlinks. Then, when each of these are clicked, JavaScript opens up the links in a new tab. When the Next button is clicked, JavaScript closes the tabs.
First, create a question and use the Rich Content Editor's HTML/Source view "<>" to update the question text with the below:

Click to write question text.

 


 


 


Then, add the below to the question's JavaScript in the OnReady section:
jQuery("#link1").on('click',function(){
var link1 = window.open('http://google.com', '_blank');

jQuery("#NextButton").on('click',function(){
link1.close();

    });

});


jQuery("#link2").on('click',function(){
var link2 = window.open('http://bing.com', '_blank');

jQuery("#NextButton").on('click',function(){
link2.close();

    });

});


jQuery("#link3").on('click',function(){
var link3 = window.open('http://yahoo.com', '_blank');

jQuery("#NextButton").on('click',function(){
link3.close();

    });

});


Leave a Reply