Access SVG with code | Expert mode

Since Webflow doesn’t allow more than 10000 charchter in its custom code embeds, I had to find a way to inject an SVG image using the object method like so:

<object class="object" type="image/svg+xml" data=""></object>

Now the question is, how do I access (with javascript) the document (svg) that is contained inside the object ? basically, I would like to target the svg element, and set its opacity to 0.5 Please see screenshot bellow:

Here is my codpen:

Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Hi @anthonysalamin the issue why it is IMO impossible to do that without fighting CORS is that image has to be on the same domain and with SVG link you are trying get inside private #document to get<svg> tag.

When you run code on local server (I have done it now) there is no issue at all as JS and image (svg) are on same domain. I have run to similar issue I think 1 year ago when I have tried to generate average color from image with “color thief” library. It is how it is and we can do nothing about these WF pitfalls.

easily create an github repository and put unlimited files in it.