svg:在当前帧中打开(xlink:href)另一个 svg 图像 - 跨浏览器噩梦?
我已经为这个问题苦苦挣扎有一段时间了,我希望得到一些帮助/建议。
我有一个 svg 图形,已嵌入到 iframe 中(我知道这很恶心,但我们已经创建了自己的仪表板/小部件应用程序,这是将现有 svg 框架移植到小部件中的最简单方法)。我需要能够将这些 svg 图形链接到其他 svg 图形,并且我需要它们在同一个 iframe 中打开,目前这让我发疯。
我发现这篇文章讨论了 svg 中的链接 的方法,但是,比较底部的似乎表明在 IE(至少 7)中不可能在除“当前窗口”之外的任何内容中打开链接。我尝试过的所有事情似乎都是这种情况,但希望在互联网领域的某个地方,有人找到了解决这个问题的方法。
这是我尝试过的:
1. <a xlink:href='<path to new embedded graphic>' target='<iframeName>' ... />
Chrome 13:完美运行,在正确的框架中打开!
Firefox 6.0.2:尝试在新选项卡中打开
IE 9.0.8: 尝试在新选项卡中打开
2. <a xlink:href='<path to new embedded graphic>' xlink:show='replace' ... />
Chrome 13: 将 svg 图形替换为我想要的文件,但是,因为我要替换为包含以下内容的 ASP 页面嵌入的 svg 图形,我最终在我的页面上得到了“嵌套”效果。
Firefox 6.0.2:与 Chrome 类似 - 就地加载但发生嵌套,尽管在 FF 中图形甚至不加载。
IE 9.0.8:与 Chrome 类似,就地加载,但会发生嵌套。
似乎设置目标框架是我想要的方式,但是有没有办法让它在 FF 和 IE 中工作?有人在这方面取得过成功吗?
我尝试尝试的另一件事是在单击链接时在 javascript 中设置框架的 window.document.location.href 。但事实证明这很难做到,而且我实际上只在 Chrome 中尝试过。在我浪费太多时间之前,我希望得到一些建议。
I have been bashing my head against this problem for awhile now and I was hoping for some help/advice.
I have an svg graphic which I have embedded into an iframe (icky I know, but we have created our own dashboard/widget application, and this was the easiest way to port our existing svg framework into the widget). I need to be able to have those svg graphics link to other svg graphics, and I need them to open in the same iframe, which at the moment is driving me mad.
I found this post which talks about methods of linking in svg, however, the comparison at the bottom seems to indicate that it is impossible in IE (7 at least) to have a link open in anything but the "current window". This seems to be the case in everything I have tried, but was hoping that somewhere out there in internet-land, someone has found a work around for this.
Here is what I've tried:
1. <a xlink:href='<path to new embedded graphic>' target='<iframeName>' ... />
Chrome 13: Works perfect, opens in correct frame!
Firefox 6.0.2: Attempts to open in a new tab
IE 9.0.8: Attempts to open in a new tab
2. <a xlink:href='<path to new embedded graphic>' xlink:show='replace' ... />
Chrome 13: Replaces the svg graphic with my desired file, however, since I am replacing with an ASP page that contains the embedded svg graphic, I end up getting a 'nested' effect on my page.
Firefox 6.0.2: Similar to Chrome - loads in place but nesting occurs, although in FF the graphic does not even load.
IE 9.0.8: Similar to Chrome, loads in place but nesting occurs.
It seems as if setting the target frame is the way I want to go, but is there anyway to make it work in FF and IE? Has anyone been successful with this?
The other thing I am attempting to try is setting the frame's window.document.location.href in javascript when the link is clicked. It's proving tricky to do though, and I have really only been attempting in Chrome. I was hoping for some advice before I wasted too much time on it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,以下内容在 IE9、Chrome 13 和 FF 6 中对我来说效果很好:
这会在父窗口中打开图形,这恰好是我的 iFrame。
Turns out the following worked just fine for me in IE9, Chrome 13 and FF 6:
This opens up the graphic in the parent window, which happens to be my iFrame.