svg 打開新的窗口

< 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 >
< 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>   
但是經過 測試 在IE7中會有問題  最後一個打不開,去掉new 之後就能打開了,難道是ie7不支持 target 屬性?
期待高手回答

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章