L
lvqher
Unregistered / Unconfirmed
GUEST, unregistred user!
我正在做一个基于ActiveX控件的项目,就是IE里面嵌入一个ActiveX,在ActiveX里面准备提交WEBSERVER一些重要的客户资料,我希望这些资料,比如用户,密码,手机号等,不出这个ActiveX,直接在ActiveX里面提交,我设计了这样的架构,用ActiveX提供一个Submit方法供HTML页面的JAVASCRIPT函数去调用,然后用这个方法去使用TWebBrowser去提交到WebServer,然后等ActiveX通过TWebBrowser收到WEBSERVER应答数据后,整个html显示新的数据,就等于是产生了一个新页面,这里的新页面要求不是在ActiveX中产生,而是在IE中产生,这时候原来的页面内容(HTML+ACTIVEX)不存在了。我的HTML代码和ActiveX的submit方法的代码我附在后面,现在的问题是我想WEBSERVER POST数据OK,也收到了回应,我如何才能把这些数据在IE上表现出来,我的IE如何才能像跳转到了其他页面那样产生一个新的应答页面。
HTML文本:
<html>
<head>
<title>用户登陆</title>
<meta http-equiv="Content-Type"
content="text/html;">
<LINK href="../theme/Master.css"
rel="stylesheet"
type="text/css">
<script language="JavaScript"
src="../script/date.js"></script>
<script language="JavaScript">
</script>
<script language="JavaScript">
function validate_form()
{
validity = true
// assume valid
alert(document.form.safeEdit1.passwdtext);
document.form.userinfo.submit(document.form.loginid.value);
document.form.userinfo.reset();
return false;
}
</script>
</head>
<body >
<FORM name="form"
method=post onSubmit="return validate_form()">
<table border="0"
cellpadding="0"
cellspacing="0"
width="486"
align="center">
<tr>
<td rowspan="2"">
<table width="85%"
border="0"
cellspacing="2"
cellpadding="2"
align="center">
<tr>
<td>
<div align="center">
<table width=230 height="100"
border=0 cellspacing=1>
<tbody>
<tr>
<td nowrap>用 户 号:</td>
<td nowrap>
<input size="19"
maxlength=19 name=loginid minlength="8">
</td>
</tr>
<tr>
<td nowrap>登录密码:</td>
<td nowrap>
<OBJECT
id="userinfo"
classid="clsid:56F64A87-4EC1-438C-BD8C-34F114B8FEA1"
codebase="userinfo.inf"
width=200
height=160
align=center
hspace=0
vspace=0
>
</OBJECT>
</br>
</td>
</tr>
<tr align=middle>
<td nowrap colspan=2 height=43>
<div align="center">
<input type=submit height=26 width=61 name=submit>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><font color="#FF0000">注意:</font></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td><img src="../images/spacer.gif"
width="1"
height="4"
border="0"></td>
</tr>
<tr>
<td><img src="../images/spacer.gif"
width="1"
height="285"
border="0"></td>
</tr>
</table>
</form>
</html>
SUBMIT方法:
Memo1.Lines.Add('DEbug start');
WebBrowser := TWebBrowser.Create(Self);
Self.ActiveFormControl.ClientSite.GetContainer(spIE);
if not Assigned(spIE) then Exit;
spIE.QueryInterface(IID_IHTMLDocument2,spDoc);
if not Assigned(spDoc) then Exit;
LocalUrl:= Trim(spDoc.url);
Memo1.Lines.Add(LocalUrl);
Memo1.Lines.Add(Globalstr);
EncodedDataString := 'loginid=' + HTTPEncode(LoginId) + '&' + 'password=' + HttpEncode(Globalstr);
PostData := VarArrayCreate([0, Length(EncodedDataString) - 1], varByte);
for I := 1 to Length(EncodedDataString) do
PostData[I-1] := Ord(EncodedDataString);
Headers := 'Content-Type: application/x-www-form-urlencoded' + #10#13;
ConfigName := filepath+'/'+'config.ini';
Memo1.Lines.Add(ConfigName);
JspIni := TIniFile.Create(ConfigName);
jspIndex:= JspIni.ReadString('Jsp','JspIndex','validateFinish.jsp');
JspIni.Free;
Memo1.Lines.Add(jspIndex);
JspUrl := GetNewUrl(LocalUrl,jspIndex);
Memo1.Lines.Add(JspUrl);
JspUrl := 'http://127.0.0.1:9000/sd/validateFinish.jsp';
WebBrowser.Navigate(JspUrl, EmptyParam,EmptyParam, PostData, Headers);
{
while WebBrowser.Busy do
Application.ProcessMessages;
}
repeat
Application.ProcessMessages ;
until(not WebBrowser.Busy);
if WebBrowser.document <> nil then
begin
doc := WebBrowser.document as Ihtmldocument2;
all := doc.all;
item:=all.item(0,varEmpty);
Memo1.Lines.Add(item.innerhtml );
end;
MEMO是一个调试工具,目前meno里确实能取到webserver返回的数据,我该怎么样把这个数据填充到页面上呢?(不是放到TWebBrowser容器里)
HTML文本:
<html>
<head>
<title>用户登陆</title>
<meta http-equiv="Content-Type"
content="text/html;">
<LINK href="../theme/Master.css"
rel="stylesheet"
type="text/css">
<script language="JavaScript"
src="../script/date.js"></script>
<script language="JavaScript">
</script>
<script language="JavaScript">
function validate_form()
{
validity = true
// assume valid
alert(document.form.safeEdit1.passwdtext);
document.form.userinfo.submit(document.form.loginid.value);
document.form.userinfo.reset();
return false;
}
</script>
</head>
<body >
<FORM name="form"
method=post onSubmit="return validate_form()">
<table border="0"
cellpadding="0"
cellspacing="0"
width="486"
align="center">
<tr>
<td rowspan="2"">
<table width="85%"
border="0"
cellspacing="2"
cellpadding="2"
align="center">
<tr>
<td>
<div align="center">
<table width=230 height="100"
border=0 cellspacing=1>
<tbody>
<tr>
<td nowrap>用 户 号:</td>
<td nowrap>
<input size="19"
maxlength=19 name=loginid minlength="8">
</td>
</tr>
<tr>
<td nowrap>登录密码:</td>
<td nowrap>
<OBJECT
id="userinfo"
classid="clsid:56F64A87-4EC1-438C-BD8C-34F114B8FEA1"
codebase="userinfo.inf"
width=200
height=160
align=center
hspace=0
vspace=0
>
</OBJECT>
</br>
</td>
</tr>
<tr align=middle>
<td nowrap colspan=2 height=43>
<div align="center">
<input type=submit height=26 width=61 name=submit>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><font color="#FF0000">注意:</font></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td><img src="../images/spacer.gif"
width="1"
height="4"
border="0"></td>
</tr>
<tr>
<td><img src="../images/spacer.gif"
width="1"
height="285"
border="0"></td>
</tr>
</table>
</form>
</html>
SUBMIT方法:
Memo1.Lines.Add('DEbug start');
WebBrowser := TWebBrowser.Create(Self);
Self.ActiveFormControl.ClientSite.GetContainer(spIE);
if not Assigned(spIE) then Exit;
spIE.QueryInterface(IID_IHTMLDocument2,spDoc);
if not Assigned(spDoc) then Exit;
LocalUrl:= Trim(spDoc.url);
Memo1.Lines.Add(LocalUrl);
Memo1.Lines.Add(Globalstr);
EncodedDataString := 'loginid=' + HTTPEncode(LoginId) + '&' + 'password=' + HttpEncode(Globalstr);
PostData := VarArrayCreate([0, Length(EncodedDataString) - 1], varByte);
for I := 1 to Length(EncodedDataString) do
PostData[I-1] := Ord(EncodedDataString);
Headers := 'Content-Type: application/x-www-form-urlencoded' + #10#13;
ConfigName := filepath+'/'+'config.ini';
Memo1.Lines.Add(ConfigName);
JspIni := TIniFile.Create(ConfigName);
jspIndex:= JspIni.ReadString('Jsp','JspIndex','validateFinish.jsp');
JspIni.Free;
Memo1.Lines.Add(jspIndex);
JspUrl := GetNewUrl(LocalUrl,jspIndex);
Memo1.Lines.Add(JspUrl);
JspUrl := 'http://127.0.0.1:9000/sd/validateFinish.jsp';
WebBrowser.Navigate(JspUrl, EmptyParam,EmptyParam, PostData, Headers);
{
while WebBrowser.Busy do
Application.ProcessMessages;
}
repeat
Application.ProcessMessages ;
until(not WebBrowser.Busy);
if WebBrowser.document <> nil then
begin
doc := WebBrowser.document as Ihtmldocument2;
all := doc.all;
item:=all.item(0,varEmpty);
Memo1.Lines.Add(item.innerhtml );
end;
MEMO是一个调试工具,目前meno里确实能取到webserver返回的数据,我该怎么样把这个数据填充到页面上呢?(不是放到TWebBrowser容器里)