Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SVG在IE6/7/8中,如何使SVG元素在其他HTML元素之前捕获鼠标事件_Javascript_Internet Explorer 8_Internet Explorer 6_Internet Explorer 7_Svg - Fatal编程技术网

Javascript SVG在IE6/7/8中,如何使SVG元素在其他HTML元素之前捕获鼠标事件

Javascript SVG在IE6/7/8中,如何使SVG元素在其他HTML元素之前捕获鼠标事件,javascript,internet-explorer-8,internet-explorer-6,internet-explorer-7,svg,Javascript,Internet Explorer 8,Internet Explorer 6,Internet Explorer 7,Svg,我在html中嵌入了SVG(使用adobe SVG viewer)并在IE中浏览,我在SVG元素上添加了鼠标侦听器,但我总是在其他html元素之后捕获事件,如何使SVG元素首先在IE中捕获鼠标事件,以便我可以决定是否取消该事件 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>SVG in IE &

我在html中嵌入了SVG(使用adobe SVG viewer)并在IE中浏览,我在SVG元素上添加了鼠标侦听器,但我总是在其他html元素之后捕获事件,如何使SVG元素首先在IE中捕获鼠标事件,以便我可以决定是否取消该事件

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>SVG in IE </title>
    <script type="text/javascript"><!--
    // <![CDATA[
        function init(){
            var canvas = document.getElementById('canvas');
            var embedNode = document.getElementById('embedNode');
            var svg = embedNode.window.document.documentElement;

            svg.addEventListener('mousedown', function(){
                trace('mouse down on svg, how to make the SVG element capture mouse event before the other HTML elements');
            }, false);//The third parameter can only be 'false'

            embedNode.onmousedown = function(){
                trace('mouse down on embedNode');
            };

            canvas.onmousedown = function(){
                trace('mouse down on canvas');
            };

        }

        function trace(text){
            var logger = document.getElementById('logger');
            logger.value += text + '\n';
        }
    // ]]>--></script>
    </head>
    <body onload='init();'>
    <textarea id='logger' style='height:200px;'></textarea>
    <div id='canvas' style='width:300px; height:400px;' >
        <embed id='embedNode' onload = 'initEvents();' src="aaa.svg" width="100%" height="100%" type="image/svg+xml" wmode='transparent' pluginspage="http://www.adobe.com/svg/viewer/install/" />
    </div>
    </body>
    </html>

您应该指定IE的哪个版本。IE9之前的IE可以使用svg吗?你必须使用Adobe Viewer吗,它已经有一段时间没有维护了?你试过SVGWeb吗?
<?xml version='1.0' encoding='UTF-8'?>
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' >
    <rect x='0' y='0' width = '500px' height='500px' fill='#EEEEEE'/>
</svg>
mouse down on embedNode
mouse down on canvas
mouse down on svg, how to make the SVG element capture mouse event before the other HTML elements