<
svg
>
< script type ="text/javascript" >
<![CDATA[
var xlinkNS = "http://www.w3.org/1999/xlink";
var someLinks = "http://dotnet.aspx.cc";
function OpenNewWindow()
{
try
{
window.open(someLinks);
}
catch (er)
{
browserEval("window.open('" + someLinks + "')");
}
}
function alternativeOpenWindow(evt,url)
{
evt.target.parentNode.setAttributeNS(xlinkNS,"href",url);
}
]]>
</ script >
< g id ="moreAlarmG" onclick ="OpenNewWindow()" >< text x ="160" y ="14" > Open Window </ text ></ g >
</ svg >
< script type ="text/javascript" >
<![CDATA[
var xlinkNS = "http://www.w3.org/1999/xlink";
var someLinks = "http://dotnet.aspx.cc";
function OpenNewWindow()
{
try
{
window.open(someLinks);
}
catch (er)
{
browserEval("window.open('" + someLinks + "')");
}
}
function alternativeOpenWindow(evt,url)
{
evt.target.parentNode.setAttributeNS(xlinkNS,"href",url);
}
]]>
</ script >
< g id ="moreAlarmG" onclick ="OpenNewWindow()" >< text x ="160" y ="14" > Open Window </ text ></ g >
</ svg >
来源:http://blog.csdn.net/net_lover/archive/2007/02/08/1505609.aspx
另外还有一种方式就是将要点击的元素 放到<a></a>中如下(来自IBM)
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat-20030114.dtd">
<!-- Created by SVGDeveloper 1.0 -->
<svg>
<a xlink:href="http://www.w3.org//Graphics//SVG//Overview.htm8">
<rect x="10" y="10" width="100" height="30" rx="10" ry="10"
style="fill:lightgrey"/>
<text x="30" y="30" font-size="12">Click here</text>
</a>
<a xlink:href="http://www.ibm.com//developerworks/">
<circle cx="100" cy="100" r="50" style="fill:grey"/>
<text x="80" y="100" font-size="12">Or here</text>
</a>
<a xlink:href="http://www.baidu.com" target="new" xmlns="http://www.w3.org/2000/svg">
<polygon
points="60 160,165 172,180 60,290 290,272 280,172 285,250 255"
style="fill:dimgrey"/>
<text x="160" y="200" font-size="12">Or even here</text>
</a>
</svg>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat-20030114.dtd">
<!-- Created by SVGDeveloper 1.0 -->
<svg>
<a xlink:href="http://www.w3.org//Graphics//SVG//Overview.htm8">
<rect x="10" y="10" width="100" height="30" rx="10" ry="10"
style="fill:lightgrey"/>
<text x="30" y="30" font-size="12">Click here</text>
</a>
<a xlink:href="http://www.ibm.com//developerworks/">
<circle cx="100" cy="100" r="50" style="fill:grey"/>
<text x="80" y="100" font-size="12">Or here</text>
</a>
<a xlink:href="http://www.baidu.com" target="new" xmlns="http://www.w3.org/2000/svg">
<polygon
points="60 160,165 172,180 60,290 290,272 280,172 285,250 255"
style="fill:dimgrey"/>
<text x="160" y="200" font-size="12">Or even here</text>
</a>
</svg>
但是经过 测试 在IE7中会有问题 最后一个打不开,去掉new 之后就能打开了,难道是ie7不支持 target 属性?
期待高手回答