我正在使用Intranet。使用VBA我必须从列表中关闭某个日期。VBA/Internet Explorer/Javascript:如何从同一个Internet Explorer打开一个JavaScript窗口?
- 我选择了日期。然后点击链接关闭(而不是按钮),这触发了一个JavaScript。
选择所有日期:
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窗口,或者在新窗口中打开javascript窗口时如何获取元素或设置值或单击新窗口的元素?
我试图使用shell窗口搜索所有打开的窗口与标题和locationurl,但我没有找到特定的窗口出于某种原因。
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
请指教。
我真的不是故意是粗鲁的,但你应该认真考虑升级你对web开发的所有知识。这看起来很像我在1999年左右所做的,而且也感觉不好。这是一款新软件,还是您从10年前开始制作软件的人那里继承?通过用现代方法重做这一点,您将为您的客户/雇主节省大量金钱,并且您自己承受很大的压力。 –
嗨安德烈斯。我根本没有被冒犯。我完全理解你的关心。你不是第一个对我的代码有这种想法的人。但是Javascript是由第三方编写的,我只是想让数据达到最佳效果。公司不希望花更多的钱聘用和专家程序员。所以我正在同时学习和工作。我很高兴我正在学习。 听起来像你一定是一个非常好的程序员。你认为这个问题有解决方案吗? – Arif