I have an SVG graphic embedded via an object tag.
<!DOCTYPE html>
<html>
<head>
<title>myTitle</title>
<script type="text/javascript" src="script.js"></script>
<link href="box.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id ="objectcontainer">
<div id="displaybox" style="display: none;"></div>
<object id = "mainSVG" type="image/svg+xml" data="map_complete.svg">
<img id="svgPic" src="map_complete.svg" alt="Browser fail"/>
</object>
</div>
</body>
</html>
There is a link in SVG:
<a id="emerBtn" xlink:href="emergency.html" onmouseover="return playVideo()" target="_parent">
The mouse over event should fire the following:
function playVideo(){
var doc = document.parentNode;
var elem = document.parentElement;
var otherElem = document.documentElement.parentElement;
var thediv = document.getElementById('displaybox');
if(wasViewed == false)
{
if(thediv.style.display == "none"){
wasViewed = true;
thediv.style.display = "";
thediv.innerHTML = "<div id='videocontainer'><video autoplay controls style='display:block; margin-left:auto;" +
"margin-right:auto; margin-top:150px; margin-bottom:auto; width:600px'>" +
"<source src='video.mp4' type='video/mp4'>HMTL5-Video not supported!</video>" +
"</div><a href='#' onclick='return palyVideo();'>CLOSE WINDOW</a>";
}else{
thediv.style.display = "none";
thediv.innerHTML = '';
}
}
else{
thediv.style.display = "none";
thediv.innerHTML = '';
}
return false;
}
My problem is that I cannot access the "displaybox" from svg. I tried .parentNode, .parentElement, document.documentElement.parentElement etc. But all the time the parent / node is null.
Does anyone know how to access "external" HTML elements from a / svg object?
source
share