jsp中用js添加节点添加不上

hanyingjun 发布于 2013/05/13 09:45
阅读 312
收藏 0
<?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.dtd">
<%@ page language="java" contentType="application/xhtml+xml; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>


<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript">

 function han(){
   var svgNode=document.getElementsByTagName("head").item(0);
   var flag=svgNode.hasChildNodes();
   alert(svgNode.childNodes.length);
   alert(flag);
   var lineNode=document.createElement("line");
   lineNode.setAttribute("x1","78");
   lineNode.setAttribute("y1","90");
   lineNode.setAttribute("x2","300");
   lineNode.setAttribute("y2","200"); 
   lineNode.setAttribute("style","stroke:rgb(99,99,99);stroke-width:2");
   svgNode.appendChild(lineNode);
 }
</script>
<head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
    <title>显示</title>
</head>

<body >

<s:form action="/ptpAction_find" id="show" name="show" namespace="/" method="post">
 查看两点之间信息:从
 <s:textfield id="id1" name="id1"></s:textfield>到<s:textfield id="id2" name="id2"></s:textfield>
 <s:submit value="提交"  onclick="han()"></s:submit>
</s:form>
<div>
<svg  width="1500" height="1500" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<s:iterator value="#request.list" var="l">
  <s:property  value="asdasdasd"/>
  
  <s:property value="#l.x"/>
  <s:property value="#l.y"/>
  <circle cx="<s:property value="#l.x"/>" cy="<s:property value="#l.y"/>" r="8" stroke="black"
stroke-width="2" fill="red">
  </circle>
  <text id="<s:property value="#l.id"/>" font-size="8pt" x="<s:property value="#l.x"/>" y="<s:property value="#l.y"/>" fill="black" ><s:property value="#l.id"/></text>
</s:iterator>
</svg>
</div>

</body>
</html>
加载中
返回顶部
顶部