我正在内部网工作。使用VBA,我必须从列表中关闭一些日期。
选择了所有日期:
html.getElementsByName("selectall")(0).Click
单击该链接以关闭日期.
html.getElementsByTagName("a")(0).Click Do While ie.Busy = True Or ie.readyState <> 4: DoEvents: Loop
部分javascript
{
//alert(xxx)
document.first.deletepids.value = xxx
window.open('closeallocation.asp?hotelid='+hotelid+'&roomtype='+roomtype+'&allocxid='+allocxid,'','toolbar=no,scrollbars=yes,width=500,height=330,top=50,left=80')
//window.open('closeallocation.asp?deletepids='+xxx+'&hotelid='+hotelid+'&allocxid='+allocxid)
}
else
{
if(confirm("Room(s) already having bookings for required dates.Do you wish to continue ?"))
{
document.first.deletepids.value = xxx
window.open('closeallocation.asp?hotelid='+hotelid+'&roomtype='+roomtype+'&allocxid='+allocxid,'','toolbar=no,scrollbars=yes,width=500,height=330,top=50,left=80')
}
else
return false;
}
如何使用VBA打开同一个窗口中的javascript窗口,或者当它在新窗口中打开时,如何获取元素或设置值,或者单击新窗口的元素?
我尝试过使用shell窗口搜索所有打开的窗口中的标题和位置,但由于某种原因,我没有找到该窗口。
Dim ow As ShellWindows
Dim fw As Variant
Dim html As HTMLDocument
Dim ie As InternetExplorer
Set ie = New InternetExplorer
Set ow = New ShellWindows
For Each fw In CreateObject("Shell.application").Windows
'On Error GoTo ErrorMsg
If fw = "Internet Explorer" Then
If InStr(fw.LocationURL, "displayhotelallocsummary.asp") <> 0 Then
Exit For
End If
End If
Next fw
Set ie = fw
Set html = ie.document
请给我建议。
发布于 2016-11-24 11:38:04
嘿,我想我有个解决办法给你。
下面的函数允许您激活所需的窗口,以便分析其HTML代码。
ie = ActivateWindow(path)
并将新页面的路径作为参数发布于 2016-11-24 12:00:43
1. How do I open the javascript window in the same window?
window.open('closeallocation.asp?hotelid=2&roomtype=3','_self','toolbar=no,scrollbars=yes,width=500,height=330,top=50,left=80')
_self
参数指示URL将替换当前页面
2. Or when it opens in a new window how do get elements or set value or click on the element of the new window?
可以通过querystring传递参数。
var myWindow = window.open('closeallocation.asp?hotelid=2&roomtype=3','','toolbar=no,scrollbars=yes,width=500,height=330,top=50,left=80');
在上面的示例中,您要传递两个参数(hotelid=2 and roomtype=3
)
https://stackoverflow.com/questions/40784159
复制相似问题