日期:2014-05-18  浏览次数:20940 次

javascro[t 调用ocx返回值错误?
<html:html lang="true">
  <head>
  <html:base />
  <title>event.jsp</title>
  <SCRIPT LANGUAGE="javascript" FOR="UserControl1" EVENT="ondata()">  
  <!--  
  UserControl1_ScanOK();  
  -->  
  </SCRIPT>  
  <SCRIPT ID="clientEventHandlersJS" LANGUAGE="javascript">
  function UserControl1_ScanOK()  
  {  
  var xml=UserControl1.get_xml();
  alert(xml); window.location.href="showOcx.do?method=ocxEvent&xml="+UserControl1.get_xml();
  }  
  </script>
  </head>
  <OBJECT
  id="UserControl1"
  classid="clsid:9295F813-51D4-43A5-918B-4A82B6410176"
  codebase="http://192.168.1.24:8080/kj133/ocx/eventProj1.ocx#version=1,1,20,8"
  width=350
  height=250
  align=center
  hspace=0
  vspace=0
  >
  <body>
   
  </body>

主要是调用eventProj1.ocx控件的get_xml()方法,在执行到alert(xml),可以弹出数据,虽然数据是
乱码,但是在showOcx.do?method=ocxEvent方法里面我用
request.getParameter("xml").length()长度却是0,也就是说数据并没有传到Action里面去,其中
get_xml返回的是字节流,我怎么才能在后台解析它?

------解决方案--------------------
你先把找个url打出来看看url中有没有xml的数据
 "showOcx.do?method=ocxEvent&xml="+UserControl1.get_xml(); 

如果有的话,你看看数据里有没有&号或特殊字符之类

你先把url打出来,然后贴出来看看。


------解决方案--------------------
function UserControl1_ScanOK()
{
var xml=UserControl1.get_xml();既然你这里已经附值了 
alert(xml); window.location.href="showOcx.do?method=ocxEvent&xml="+xml;这里直接用xml这个变量么好了
还去取一次 浪费资源
}
------解决方案--------------------
我不是很明白你的意思,可以说仔细点吗?