87,922
社区成员
发帖
与我相关
我的任务
分享
var embeds = document.getElementsByTagName("embed");
while(embeds.length > 0) {
embeds[0].parentNode.removeChild(embeds[0]);
}
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
onload="init(evt);" onmousemove="findNearest(evt);" onunload="unload();">
<style type="text/css"><![CDATA[
svg{
fill:none;
stroke:black;
stroke-width:1;
}
]]>
</style>
<script type="text/javascript" xlink:href="svg.js"></script>
<rect x="-1" y="-1" width="105%" height="105%" fill="none" pointer-events="all"></rect>
<g id="content">
</g>
</svg>
var Ext,myExt,SVG={},doc,root,ns;
/**
* 查找最近的点,并获取描述
* @param {} e
*/
findNearest=function(e){
var el=e.target,
child=el.firstChild,
desc;
while(child){
if(child.nodeName=='desc'){
try{
alert(getText(child));
desc=Ext.decode(getText(child));
}
catch(ex){alert(ex.message);}
break;
}
child=child.nextSibling;
}
};
/**
* svg文档加载初始化,主要为svg文档与html文档建立起联系
* @param {} e
*/
init=function(e){
doc=e.target.ownerDocument;
root=doc.documentElement;
ns=root.namespaceURI;
doc.window=window;
var parent=window.parent;
Ext=parent.Ext;
myExt=parent.myExt;
Ext.applyIf(Number.prototype,parent.Number.prototype);
Ext.applyIf(Date.prototype,parent.Date.prototype);
};
unload=function(evt){
alert('unloadSVG');
};
/**
* 加载数据
*/
loadData=function(cfg,w,h){
……
};