Adding allow="camera" to HTML element

So there is no way to use a camera with chrome since they depreciated the iframe and the following has to be implemented in the top level HTML

However, we have not been given a method to change the attributes of iframes in wix code besides the allow full screen and the src ones.

has anyone found a backend workaround to use real jquery to do something like:

  1. Using attr :
$w("#iframe").attr("allow", "camera");

or
2) Using DOM object:

$w("#iframe")[0].setAttribute("allow", "camera");

Thank you all for your time.

I really wish wix would add a handler to change the allow attributes of the iframes since they wont allow us to embed html in our sites.

1 Like

It seems like a similar question was raised in this forum post, please check it out: https://www.wix.com/corvid/forum/community-feature-request/how-allow-access-to-the-camera-via-chrome-1
You may also find this article useful: https://support.wix.com/en/article/corvid-working-with-the-html-element

I suspect you should be able to add the attribute in the way you describe. You’ll have to get creative to find a way to select the right iFrame. Or maybe there’s not much harm in adding the attribute to every iFrame on the page. I don’t think the function they have on $ is jQuery, but you don’t need jQuery to select elements: just use document.querySelector() or querySelectorAll().

Use the Tracking & Analytics feature in the site dashboard to inject code to the site.

Hi Lee,
I JUST WANT TO EXPRESS ABSOLUTE GRATITUDE TO YOU.
I spent 6 months trying to figure out a way to accomplish this and you just gave me the key to do it.
It works and I am absolutely astonished. I seriously do not know how to thank you enough.
-Logan

There are so many people searching for this answer, and I want them to know how to do it, but I also am afraid of wix patching it.

Hi Logan,

I would really appreciate if you share with me exactly the way you solved it.
I have the same problem but with the microphone.

And I couldn’t quite understand Lee’s suggestion.
I’d be happy to hear from you.

Thanks,
Shelly

Yes, please post your solution! Much appreciated!

Thanks to lee’s hints and Logan’s confirmation that there was, indeed, a solution I was able to get access to the camera on both Chrome and Safari by adding the following code snippet under the “Tracking & Analytics” section of the dashboard as part of Body-End code. I know just enough about coding to be pretty dangerous so use with much discretion. If someone has suggested improvements, I welcome them.

When adding this code, I set it to add code to “all Pages” and to “Load code once”