I am attempting to load an external SVG file and then add additional SVG elements on top of it. However, I am encountering an error message when I try to do so.
Error message: Failed to execute 'appendChild' on 'Node': Only one element on document allowed
This error occurs when inspecting within Chrome.
Below is the HTML code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Hello World</title>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="mySvg">
<circle cx="40" cy="30" r="15" fill="#FF00FF"
stroke="#000000" stroke-width="2" />
</svg>
<object data="img/drawing.svg" type="image/svg+xml"
align="center" id="svgDrw" height="80vh"></object>
<script type="text/javascript" src="js/problem.js"></script>
</body>
</html>
The problem seems to be related to the JavaScript file (problem.js) included in the HTML above. The script attempts to add a rectangle element dynamically over the loaded SVG, but encounters an error in doing so.
If you have any insights or solutions to resolve this issue, please let me know. Thank you!