Nachtrag: Via <object> kann man auch aus dem einbindenden HTML-Dokument ins SVG eingreifen.
test.html
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<title>Test</title>
<script>
document.addEventListener("DOMContentLoaded", function()
{
const obj = document.querySelector("object");
obj.addEventListener("load", function()
{
obj.contentDocument.querySelector("circle").setAttribute("fill","red");
});
});
</script>
</head>
<body>
<object data="test.svg" type="image/svg+xml"></object>
</body>
</html>
test.svg
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="20"/>
</svg>
Grüße,
Thomas