2015-05-28 156 views
2

我在使用Internet Explorer API时遇到问题。 早些时候,我用来连接,授权,并按下按钮使用FoxPro和Internet Explorer 10

ie = CREATEOBJECT("InternetExplorer.Application") 
ie.navigate('site') 
ie.document.all("login").value = login 
ie.document.all("password").value = password 
ie.document.all("auth").click 

现在这个网站不支持Internet Explorer或,而在网站上,不支持IE浏览器的兼容性设置。

打开兼容性设置后,我可以使用这种方式进行授权,但不能单击脚本(甚至是手动)之后,兼容设置关闭时我无法授权和手动单击。

请告诉我,另一种方式来打开资源管理器,阅读内容,填写字段,并单击按钮和脚本链接?

回答

0

我会做如下:

IE = CreateObject("InternetExplorer.Application") 
IE.navigate("site") 
IE.Visible = .t. 

Do While IE.readystate <> 4 
enddo 

IE.document.getElementbyId("login").focus(1) && Mark the parameter, can be anything, no matter what. 
IE.document.getElementbyId("login").value = "login" 
IE.document.getElementbyId("password").value = "password" 
IE.document.getElementbyId("auth").click(1) && Mark the parameter, can be anything, no matter what. 

备选: ie.document.forms(0).submit(1)中的形式& & 0()被现场dependend ie.document.forms (0).elements(4).click(1)& &第四个元素是依赖于站点的地址

没有关于参数(1)的文档,只有VFP似乎需要自IE9以来。任何价值或类型都可以。

+0

我刚试过这个。关闭兼容性设置时,Internet Explorer不支持“getElementbyId”。 – kudis

+0

您是否知道,我可以使用CREATEOBJECT(“Wscript.Shell”)打开浏览器,然后单击网页上的某个按钮,或者使用CREATEOBJECT('​​HYPERLINK')执行相同的操作? – kudis

+0

我的答案不是关于GetElementbyID,而是关于click(1)中的(1)参数。这解决了你的问题。如果GetElementbyID不起作用,那是因为特定站点不允许这种访问方式。如果ie.document.all(“login”)。value适合你,那很好。您也可以使用表单(#x).Elements(#y) – Jack