Skip to content

Instantly share code, notes, and snippets.

@bsoule bsoule/index.html
Last active Mar 22, 2019

Embed
What would you like to do?
object error event
<!DOCTYPE html>
<html>
<head>
<title>test object svg reload</title>
</head>
<script>
let beeurl = "https://www.beeminder.com/legacy_images/infinibee.svg"
let noturl = "https://beeminder-dev.s3-us-west-2.amazonaws.com/not-a-valid-file-name.svg"
let svgurl = "https://s3-us-west-2.amazonaws.com/beeminder-dev/graphwith.svg"
function updateSVG(url) {
let svgObject = document.getElementById("graph")
svgObject.onload = () => {
console.log("loaded object")
}
svgObject.onerror = () => {
console.log("error object")
}
svgObject.setAttribute("data",url)
svgObject.parentNode.replaceChild(svgObject, svgObject)
}
</script>
<style>
body { text-align: center; }
</style>
<body>
<div class="panel">
<div class="main">
<object type="image/svg+xml"
data="https://www.beeminder.com/legacy_images/infinibee.svg"
id="graph"></object>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.