发布到Web窗体并在普通浏览器中显示结果 [英] Posting to a Web Form and Displaying the Result in Normal Browser

查看:61
本文介绍了发布到Web窗体并在普通浏览器中显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去两天我一直在苦苦挣扎,我以为

非常容易,就是打开一个带有表格的网页和

使用查询字符串中传递的数据填充表单(POST或

GET)。


我得到了Application.FollowHyperlink * kind * of working,但是有一些角色的双重编码有问题
问题(我不得不做特别的

数据中有+符号的东西,以及从未搞清楚为什么

一些数据被截断了)。但是当我执行FollowHyperlink,

以及得到未指定的对象错误时,Access97的问题也很糟糕。


运行时错误-2147221020(800401e4)

对象''_ Application'的方法''FollowHyperlink''失败


它可能有什么东西给该页面是.htaccess

密码保护的事实。它似乎第一次工作,提示输入

密码(但使用IE用户名/密码对话框,这对我来说似乎很奇怪,即使它是'在FireFox中打开,因为它应该),然后

然后它有时会工作第二次(没有密码提示),但

然后在此之后Access完全崩溃,或者它与上面的错误一起消失了。


即使它工作正常,我也无法传递数据,这就是
是非常复杂的,有很多外语字符和

硬回报等等,但无法使我的数据全部可靠。


我刚刚做了一些谷歌搜索并提出了这个(全部在一行):

http://groups.google.com/group/comp..../msg/7ba31bf87

26d8ad0


表示调用FollowHyper链接是这样的:


Application.FollowHyperlink strURL ,,, strOutput,msoMethodGet


或者像这样:

Application.FollowHyperlink strURL& strOutput

如果strOutput超过大约1000个字符并且

(strURL& strOutput)超过2048个字符,
可能会崩溃。我很可能

遇到其中一个或两个限制,这使得

无法使用。


之前我发现那篇帖子,我已经转向XMLHTTP了。我的

代码是由很多人从Access新闻组中的帖子中复制的。

知道你在做什么的好伙伴。我已经完成了一些简单的概念验证测试,但原版打算不在网页上显示
,但要在幕后完成所有操作不是

把它交给浏览器。我已经在我的PC上下载并安装了MSXML4,打算将它安装在目标机器上,所以我想我会使用它。但它不起作用。这是我的代码:


Dim oHttp As Object

Dim strFileName As String


设置oHttp = CreateObject(" Microsoft.XMLHTTP")

''oHttp.Open" GET"," https://www.wurlitzerbruck.com/AddRecord.php?" _

& strOutput,False

oHttp.Open" POST"," https://www.wurlitzerbruck.com/AddRecord.php" ;, _

False

oHttp.setRequestHeader" Content-Type",_

" application / x-www-form-urlencoded"

''oHttp.send'' GET

oHttp.send(strOutput)''POST

''oHttp.send(strXMLOutput)''POST


strOutput是一个标准的查询字符串(?Parameter1 = 1& Parameter2 = 2,

等)。

strXMLOutput是XML格式的查询条件。 />

如注释ou代码所示,我也尝试使用GET,并且

似乎有效,返回目标页面的HTML。但是

我不想要 - 我想让它在默认的

浏览器中显示页面。我可以使用GET(虽然更喜欢POST),

但是没有看到如何使用它在默认浏览器中加载它。

关于FollowHyperlink或XMLHTTP的任何想法?


无论如何,升级到更新版本的Access在不久的将来不是一个

选项,所以不要提它。也许一个

旧版本的MSXML会更好? (目标上的选择

机器是2,3和4)。而且,顺便说一句,我在Win2K上开发和

它将在Win2K上运行,所有这些都包含最新的服务包。


建议?


-

David W. Fenton http://www.dfenton.com/

usenet at dfenton dot com http://www.dfenton.com/DFA/

解决方案

4月5日星期四2007 18:11:23 -0500,David W. Fenton

< XX ******* @ dfenton.com.invalidwrote:


如果我不得不将值戳到网页中,我会使用

WebBrowser控件,并使用DOM(文档对象模型)。

示例:

如果WebBrowser1.LocationURL = URL_PHOENIX_LIBRARY_REFERENCE_USA和

WebBrowser1.Document.getElementsByName(" cardnum")。长度0然后

WebBrowser1.Document.All(" cardnum")。innerText =

LIBRARY_CARD_NUMBER

WebBrowser1.Document.All(" cardname")。innerText =

LIBRARY_CARD_NAME

WebBrowser1.Document.Forms(0)(" Submit")。点击

Else

MsgBox"此按钮仅在您登录

页面时有效。",vbInformation

结束如果

< clip>


Tom van Stiphout< no ************* @ cox.netwrote in

news:95 ******************************** @ 4ax.com:


如果我不得不将值戳到网页中,我会使用

WebBrowser控件,并使用DOM(文档对象模型)。

示例:

如果WebBrowser1.LocationURL = URL_PHOENIX_LIBRARY_REFERENCE_USA



WebBrowser1.Document.getElementsByName(" cardnum")。长度0然后

WebBrowser1.Document.All(" cardnum")。innerText =

LIBRARY_CARD_NUMBER

WebBrowser1.Document.All(" cardname")。innerText =

LIBRARY_CARD_NAME

WebBrowser1.Document.Forms(0)(" Submit")。点击

Else

MsgBox"此按钮仅在您登录

页面时有效。",vbInformation

结束如果


但是我最后一次检查时,网页浏览器控件至少与A97,

不相容。这是我在大约3或4年前设想的原始方式,但是可能永远不会让它工作,即使我在控制IE的版本上也是如此安装

机器。


我想我能做的就是相当于某种类型的数据库驱动的会话管理网站,并在网站上有

脚本用会话密钥存储数据并返回会话密钥作为其输出,然后使用FollowHyperlink传递

会话密钥返回一个不同的脚本,该脚本将在

浏览器中打开并显示已传递的数据。


但这肯定是这个如果没有在

网站上保存数据,应该可行吗?


-

David W. Fenton http://www.dfenton.com/

usenet at dfenton dot com < a rel =nofollowhref =http://www.dfenton.com/DFA/ta rget =_ blank> http://www.dfenton.com/DFA/


David W. Fenton写道:


Tom van Stiphout< no ************* @ cox.netwrote in

news:95 ****** **************************@4ax.com:


> In如果我不得不将值戳到网页中,我会使用WebBrowser控件,并使用DOM(文档对象模型)。
示例:
如果WebBrowser1.LocationURL = URL_PHOENIX_LIBRARY_REFERENCE_USA
WebBrowser1.Document.getElementsByName(" cardnum")。length 0然后
WebBrowser1.Document.All(" cardnum")。innerText =
LIBRARY_CARD_NUMBER
WebBrowser1 .Document.All(" cardname")。innerText =
LIBRARY_CARD_NAME
WebBrowser1.Document.Forms(0)(" Submit")。点击
Else
MsgBox"此按钮仅在您登录
页面时有效。, vbInformation
结束如果



但是网页浏览器控件至少与A97不相容,

,我上次检查。这是我在大约3或4年前设想的原始方式,但是可能永远不会让它工作,即使我在控制IE的版本上也是如此安装

机器。


我想我能做的就是相当于某种类型的数据库驱动的会话管理网站,并在网站上有

脚本用会话密钥存储数据并返回会话密钥作为其输出,然后使用FollowHyperlink传递

会话密钥返回一个不同的脚本,该脚本将在

浏览器中打开并显示已传递的数据。


但这肯定是这个如果没有在

网站上保留数据,应该可行吗?



为什么要在网络浏览器中显示数据?


您是否计划将项目添加到数据库在使用

Access前端的Web服务器上,然后查看从网站请求

时这些项目的显示方式?


我做了类似于网上商店的事情,但没有

在浏览器中查看结果。我使用xmhttp用新数据请求页面

并简单地解析它并在Access窗体中显示我需要的



我实际上按项目编号自动化了请求并且只是坐在那里

观看结果显示在表格中。



I''ve been struggling the last two days with something I thought was
very easy, which is to open a web page with a form on it and
populate the form with data passed in a query string (either POST or
GET).

I got Application.FollowHyperlink *kind* of working, but was having
problem with double encoding of some characters (I had to do special
things with + signs in the data, as well as never figuring out why
some data was getting truncated). But I''ve also had terrible
problems with Access97 just crashing when I execute FollowHyperlink,
as well as getting unspecified object errors.

Runtime Error -2147221020 (800401e4)
Method ''FollowHyperlink'' of object ''_Application'' failed

It may have something to do with the fact that the page is .htaccess
password-protected. It seems to work the first time, prompting for
the password (but using the IE username/password dialog, which seems
odd to me, even though it''s opening in FireFox, as it should), and
then it sometimes works a second time (with no password prompt), but
then after that either Access entirely crashes, or it craps out with
the error above.

Even when it worked, I was having problems passing the data, which
is quite complicated with lots of foreign-language characters and
hard returns and such, but was unable to make it reliable with all
my data.

I just did some Googling and came up with this (all on one line):

http://groups.google.com/group/comp..../msg/7ba31bf87
26d8ad0

which suggests that calling FollowHyperlink like this:

Application.FollowHyperlink strURL, , , , strOutput, msoMethodGet

or like this:

Application.FollowHyperlink strURL & strOutput

can crash if strOutput is longer than about 1000 characters and if
(strURL & strOutput) is longer than 2048 characters. I''m very likely
encountering one or both of those limitations, which makes it
unacceptable for use.

Before I discovered that post, I had already turned to XMLHTTP. My
code was copied from posts in the Access newsgroups by lots of you
good folks who know what you are doing. I had already done some
simple proof-of-concept tests, but had original intended to not
display in a web page, but to do it all behind the scenes and not
hand it off to the browser. I had downloaded and installed MSXML4 on
my PC, intending to install it on the target machines, so I figured
I''d use it. But it''s not working. Here''s my code:

Dim oHttp As Object
Dim strFileName As String

Set oHttp = CreateObject("Microsoft.XMLHTTP")
''oHttp.Open "GET", "https://www.wurlitzerbruck.com/AddRecord.php?" _
& strOutput, False
oHttp.Open "POST", "https://www.wurlitzerbruck.com/AddRecord.php", _
False
oHttp.setRequestHeader "Content-Type", _
"application/x-www-form-urlencoded"
''oHttp.send '' GET
oHttp.send (strOutput) '' POST
''oHttp.send (strXMLOutput) '' POST

strOutput is a standard query string (?Parameter1=1&Parameter2=2,
etc.).

strXMLOutput is the query criteria in XML format.

As shown with the commented-ou code, I also tried using GET, and
that would seem to work, returning the HTML of the target page. But
I don''t want that -- I want it to display the page in the default
browser. I''d be fine with using GET for this (though prefer POST),
but don''t see how to use this to load it in the default browser.

Any ideas, either on FollowHyperlink or XMLHTTP?

In any event, "upgrade to a newer version of Access" is not an
option for the near future, so don''t even mention it. Perhaps an
older version of MSXML would be better? (the choices on the target
machines are 2, 3 and 4). And, BTW, I''m both developing on Win2K and
it will be run on Win2K, all with the latest service packs.

Suggestions?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

解决方案

On Thu, 05 Apr 2007 18:11:23 -0500, "David W. Fenton"
<XX*******@dfenton.com.invalidwrote:

In cases where I had to poke values into a webpage, I would use the
WebBrowser control, and use the DOM (document object model).
Example:
If WebBrowser1.LocationURL = URL_PHOENIX_LIBRARY_REFERENCE_USA And
WebBrowser1.Document.getElementsByName("cardnum"). length 0 Then
WebBrowser1.Document.All("cardnum").innerText =
LIBRARY_CARD_NUMBER
WebBrowser1.Document.All("cardname").innerText =
LIBRARY_CARD_NAME
WebBrowser1.Document.Forms(0)("Submit").Click
Else
MsgBox "This button only works when you are on the Login
page.", vbInformation
End If
<clip>


Tom van Stiphout <no*************@cox.netwrote in
news:95********************************@4ax.com:

In cases where I had to poke values into a webpage, I would use
the WebBrowser control, and use the DOM (document object model).
Example:
If WebBrowser1.LocationURL = URL_PHOENIX_LIBRARY_REFERENCE_USA
And
WebBrowser1.Document.getElementsByName("cardnum"). length 0 Then
WebBrowser1.Document.All("cardnum").innerText =
LIBRARY_CARD_NUMBER
WebBrowser1.Document.All("cardname").innerText =
LIBRARY_CARD_NAME
WebBrowser1.Document.Forms(0)("Submit").Click
Else
MsgBox "This button only works when you are on the Login
page.", vbInformation
End If

But the web browser control is disastrously incompatible with A97,
at least, the last time I checked. That was the original way I
conceived this, about 3 or 4 years ago, but could never make it
work, even when I was controlling the version of IE on al installed
machines.

I guess what I could do is the equivalent of some kind of
database-driven session management on the website, and have the
script on the website store the data with the session key and return
the session key as its output, then use FollowHyperlink to pass the
session key back to a different script that would open in the
browser and display the data that was passed.

But surely this ought to be doable without persisting data on the
website?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/


David W. Fenton wrote:

Tom van Stiphout <no*************@cox.netwrote in
news:95********************************@4ax.com:

>In cases where I had to poke values into a webpage, I would use
the WebBrowser control, and use the DOM (document object model).
Example:
If WebBrowser1.LocationURL = URL_PHOENIX_LIBRARY_REFERENCE_USA
And
WebBrowser1.Document.getElementsByName("cardnum") .length 0 Then
WebBrowser1.Document.All("cardnum").innerText =
LIBRARY_CARD_NUMBER
WebBrowser1.Document.All("cardname").innerText =
LIBRARY_CARD_NAME
WebBrowser1.Document.Forms(0)("Submit").Click
Else
MsgBox "This button only works when you are on the Login
page.", vbInformation
End If


But the web browser control is disastrously incompatible with A97,
at least, the last time I checked. That was the original way I
conceived this, about 3 or 4 years ago, but could never make it
work, even when I was controlling the version of IE on al installed
machines.

I guess what I could do is the equivalent of some kind of
database-driven session management on the website, and have the
script on the website store the data with the session key and return
the session key as its output, then use FollowHyperlink to pass the
session key back to a different script that would open in the
browser and display the data that was passed.

But surely this ought to be doable without persisting data on the
website?


Why do you want to display the data in a web browser?

Is your plan to add items to a database on a web server using an
Access front end and then view how those items are displayed when
requested from the site?

I have done something similar to that for a web store, but did not
view the results in a browser. I used xmhttp to request the page
with the new data and simply parsed it and displayed what I needed
to know in an Access form.

I actually automated the request by item number and just sat there and
watched the results be displayed in the form.



这篇关于发布到Web窗体并在普通浏览器中显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆