SVG文件
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g id='frame'></g>
</svg>HTML文件
<html>
<head>
<title>SVG</title>
<script language="javascript">
function t1(){
var svgDocument = document.getElementById('svg').getSVGDocument();
var frame = svgDocument.getElementById('frame');
var rect1 = svgDocument.createElement('rect');
rect1.setAttribute('x', 40);
rect1.setAttribute('y', 40);
rect1.setAttribute('width', 40);
rect1.setAttribute('height', 40);
rect1.setAttribute('style', 'fill:rgb(238,238,238);stroke:none;');
frame.appendChild(rect1);
}
</script>
</head>
<body onload='t1()'>
<embed id='svg' src="polyline.svg" width="300" height="100" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" />
</body>
</html>上面的代码在IE中工作正常,FireFox中却没有显示,不知道问题出在哪里
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g id='frame'></g>
</svg>HTML文件
<html>
<head>
<title>SVG</title>
<script language="javascript">
function t1(){
var svgDocument = document.getElementById('svg').getSVGDocument();
var frame = svgDocument.getElementById('frame');
var rect1 = svgDocument.createElement('rect');
rect1.setAttribute('x', 40);
rect1.setAttribute('y', 40);
rect1.setAttribute('width', 40);
rect1.setAttribute('height', 40);
rect1.setAttribute('style', 'fill:rgb(238,238,238);stroke:none;');
frame.appendChild(rect1);
}
</script>
</head>
<body onload='t1()'>
<embed id='svg' src="polyline.svg" width="300" height="100" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" />
</body>
</html>上面的代码在IE中工作正常,FireFox中却没有显示,不知道问题出在哪里
解决方案 »
- 在网页中如何点击链接然后播放背景音乐
- 很有意义的一帖,如何在textarea中立刻显示出字体渲染效果
- 关于js给css的class动态赋值问题
- 一个基于JavaScript的Web绘制图表工具
- 菜鸟求救!如何让生成的zip文件在客户端通过link显示出来
- IE 的window.open无效了,不知道原因?
- 邪门了,怎么这样的问题都让我碰上了,费解中......................
- j2ee中table有2个需求,1.对某些列的行进行去重,2.对某些列支持正反排序,这两个功能会起冲突,贴出源码,求大家指导!
- 如何激发关于 document 的事件,通过直接点击页面而不是点按钮或其它什么的来实现
- 怎样在指定坐标(x,y,xx,yy)的矩形区域中输出一段文字?
- 如何用javascript实现图片新闻幻灯切换效果(不用flash)?
- jsp页面的框如果设为disabled,向servlet提交时取不到其值?有何办法取回原来设的值?
var rect1 = svgDocument.createElementNS('http://www.w3.org/2000/svg','rect');
rect1.setAttribute('x', 40);
rect1.setAttribute('y', 40);
rect1.setAttribute('width', 40);
rect1.setAttribute('height', 40);
rect1.setAttribute('style', 'fill:rgb(238,238,238);stroke:none;');
frame.appendChild(rect1);我这边IE,ff,chrome都测试通过了