Is it possible to change svg background image using javascript or css?

In my case, I have a background image that is set to repeat x. I was wondering if the background image could be svg, and if so, is there a way to manage its nodes via css or javascript?

I use SVGInjection to animate svg images pasted with a tag, but I could not find a way to do the same when svg is a background image.

+4
source share
2 answers

My understanding is ... background images MAY be SVG if they are loaded from a file and not embedded in the page.

To change the background through JS or CSS, you will have to have access to the embedded version.

...

body { background-image: 
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><linearGradient id='gradient'><stop offset='10%' stop-color='%23F00'/><stop offset='90%' stop-color='%23fcc'/> </linearGradient><rect fill='url(%23gradient)' x='0' y='0' width='100%' height='100%'/></svg>");
      }

... , URL- SVG. , .

0

, , , SVG ( edit: , , URL- ) , . SVG , XML/script.

, , .

, - SVG, ( , , , , ), , XSS, SVG script.

  • img
  • image
  • background-image
  • content ( )
0

All Articles