<? xml version="1.0" encoding="UTF-16" ?> <! DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd" [ <!ENTITY st0 "display:none;fill:none;stroke:#AD0012;stroke-width:2;" > ]> < svg xml:space ="preserve" width ="400" height ="400" > < desc > draw view </ desc > < defs > < menu id ="myContextMenu" > < header > Custom Menu </ header > < item onactivate ="showHelp()" > 帮助 </ item > < item id ="About" action ="About" > 关于 Adobe SVG Viewer </ item > </ menu > </ defs > < script > <![CDATA[ var newMenuRoot = parseXML( printNode( document.getElementById( 'myContextMenu' ) ), contextMenu ); contextMenu.replaceChild( newMenuRoot.firstChild, contextMenu.firstChild ); function showHelper() { alert('help'); } ]]> </ script > < rect x ="0" y ="0" width ="400" height ="400" rx ="10" ry ="10" style ="fill:none;stroke:#006300;stroke-width:1;" /> < text x ="100" y ="100" style ="font-family:'SimHei',sans-serif;pointer-events:none" > 自定义右键菜单 </ text > </ svg > 转载于:https://www.cnblogs.com/avlee/archive/2005/03/15/119035.html