我有一个通过对象标签嵌入的SVG图形。
<!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>
Run Code Online (Sandbox Code Playgroud)
在SVG中是一个链接:
<a id="emerBtn" xlink:href="emergency.html" onmouseover="return playVideo()" target="_parent">
Run Code Online (Sandbox Code Playgroud)
鼠标悬停事件应触发以下事件:
function playVideo(){
//not working, all the time null
var doc = document.parentNode;
var elem = document.parentElement;
var otherElem = document.documentElement.parentElement;
//working if triggered from index.html
var thediv = document.getElementById('displaybox');
if(wasViewed == false) //show …Run Code Online (Sandbox Code Playgroud)