Issue with iframe allow attribute being removed | XM Community
Skip to main content

Hi there,
We're trying to embed an iframe in one of our questions that requires microphone access. However, when we save the question, the allow attribute is being removed. Is there any way to prevent this behavior?

 <iframe 
src="http://myurl.com"
allow="microphone; camera"
style="width:100%; height:600px; border:none;">
</iframe>

 

Saved end result

 <iframe 
src="http://myurl.com"
style="width:100%; height:600px; border:none;">
</iframe>

 

Are you trying to add a question so that the respondent can record their answer? 


@KathyM its a bit more complex then just a recording. But yes, an iframe needs an access to microphone and camera. 


Right, but I think that Qualtrics has restrictions unless you have the Video Response question type. But even so, I am not sure that would solve your problem. 
👀 too see a solution!


@KathyM Previously, the same approach was working, so it seems this issue may be due to a recent change. Is there a setting to disable server-side sanitization for a specific question? Or is there a way to use a comment structure to bypass the sanitization for a specific code snippet?


The issue could be with the host of the content you’re trying to embed. If the “Feature-Policy” or “Permissions-Policy” HTTP Header is restricting embeds. It would have to be changed on the server where the hosted content is coming from.

I was able to recreate an iFrame with the exact code you provided.

 



@DRichcreek  I think when it comes to camera or microphone access, support is still fairly limited — it's considered experimental in some cases: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Permissions-Policy/microphone.

Out of curiosity, do you know what Qualtrics plan you're using? I'm starting to suspect that our client might be on a lower-tier plan, which could be why the allow attribute is being stripped.


@artem.alekhin We’re using XM for Customer Experience - Frontline Digital, but I’ll dig deeper into the permissions to see where there might be a disconnect to see if I can help.


Hello ​@artem.alekhin

I'm sure you may have already checked this, but I would still recommend verifying whether the "Allow All HTML Markup" and "Allow JavaScript" permissions are enabled for your account. These permissions are essential for embedding iframes with advanced attributes such as allow="microphone".


Hi,

You could try injecting your iframe via javascript instead.


@artem.alekhin I’ve tried this and its working, please review the below code:

Qualtrics.SurveyEngine.addOnload(function () {
    var iframe = document.createElement('iframe');
    iframe.src = 'https://akashdeep02007.github.io/Qualtrics---Redirect-URL/redirect.html';
    iframe.width = '100%';
    iframe.height = '600px';
    iframe.allow = 'camera; microphone; autoplay';
    iframe.style.border = 'none';
    this.getQuestionContainer().appendChild(iframe);
});

 

Below is a screenshot for the same for your quick reference.

 

 


Hi ​@artem.alekhin I’ve tried this on my end and it worked. Please review the code below and give it a try.

 

Qualtrics.SurveyEngine.addOnload(function () {
    var iframe = document.createElement('iframe');
    iframe.src = 'https://akashdeep02007.github.io/Qualtrics---Redirect-URL/redirect.html';
    iframe.width = '100%';
    iframe.height = '600px';
    iframe.allow = 'camera; microphone; autoplay';
    iframe.style.border = 'none';
    this.getQuestionContainer().appendChild(iframe);
});