我已经创建了一个使用raphaeljs库绘制各种SVG元素的页面,但我在Safari中遇到了一些问题。Safari嵌入式SVG文档类型
我正在绘制图像并使用剪切路径来遮罩某些区域。用户可以点击这些图像“通过”来放置在后面的其他图像。
这可以在firefox和chrome甚至IE中按预期工作。但在Safari中,我无法点击图片。剪切路径在Safari中似乎不起作用。
我通过this question发现,Safari的内容类型必须设置为“application/xhtml + xml”,因为它不使用html5解析器。
我试过的建议把这个在我的页面的顶部...
<?php
header('Content-type: application/xhtml+xml');
?>
...但浏览器只是输出HTML文件。
我只是想知道我需要什么的doctype,让Safari正确绘制嵌入式SVG,如Chrome和Firefox?
这是我怎么拉我的SVG图像,并且在镀铬正常工作和firefox
function myDraw(path, url, x, y, w, h, id){
//create clipPath Element
var clippath = document.createElementNS("http://www.w3.org/2000/svg","clipPath");
clippath.setAttribute("id", id);
svgcanv.appendChild(clippath);
//draw the path
var cp=paper.path(path).translate(x, y).attr({stroke: 0});
$(cp.node).appendTo('#'+id+'');
//assoc clipPath with image
var img = paper.image(url,x,y,w,h);//.attr({fill:"#111",opacity:0.7});
img.node.setAttribute("clip-path","url(#"+id+")");
img.node.setAttribute("class",id);
}
我使用raphaeljs设置画布和使用上述函数来绘制,它的工作原理除非你不能通过剪辑路径元素点击后面。所以内联SVG在Safari中不完全支持。谢谢您的帮助 – michael 2011-06-17 08:28:25