我正在使用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