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 属性?
期待高手回答

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值