我使用VBA和“过滤器数据”使用用户名密码浏览一个私有站点,
“过滤器”数据的每一行都有超链接,该超链接将我带到新的弹出窗口。
在“新”弹出窗口中,有类似
的hrefhref="/ENIT/imsscsv_download.jsp?filename=07730_Dormant_Account_07022019.csv&filepath=/dmsapp/mnt/appln/DMSWeblogic/ENIT_FILES/COMMUNICATION_LOG/SENDER/INVESTIGATION_ALERTS/07730_Dormant_Account_07022019.csv"
如何从弹出窗口中提取href值
弹出窗口的HTML代码
<html>
<head>
<title>Communication Log</title>
<LINK REL ="stylesheet" TYPE="text/css"
HREF="../css/ENIT_Table_Style.css" TITLE="Style">
<script type= "" language="javascript" src="../js/utils.js"></script>
<script type="" language="javascript" src="/ENIT/js/tablesort.js"></script>
<script>
var sentDate ='08-Feb-2019';
//sentDate = '01/29/2016';
var dt = sentDate.split(/\-|\s/) //Added By Mohsin on 14-Mar-2016 for Transactional Alert
sentDateFormatted = new Date(dt.reverse().join('/'));
function getMemberList()
{
var callbackFunction = populateMemberList;
var CMSegment = 'N';
var FNOSegment = 'N';
var CDSSegment = 'N';
var IPOSegment = 'N';
var segmentList = "";
var isInHouseMemberList = "N";
if(document.getElementById("rdBtnSegment_CM") != null && document.getElementById("rdBtnSegment_CM").checked)
{
CMSegment = 'Y';
segmentList += "CM|";
}
if(document.getElementById("rdBtnSegment_FNO") != null && document.getElementById("rdBtnSegment_FNO").checked)
{
FNOSegment = 'Y';
segmentList += "FNO|";
}
if(document.getElementById("rdBtnSegment_CDS") != null && document.getElementById("rdBtnSegment_CDS").checked)
{
CDSSegment = 'Y';
segmentList += "CDS|"; //Due to URL redirect problem '%CDS%' treat as '=S%'
}
if(document.getElementById("rdBtnSegment_IPO") != null && document.getElementById("rdBtnSegment_IPO").checked)
{
IPOSegment = 'Y';
segmentList += "IPO|";
}
if(document.getElementById("selectAll") != null && document.getElementById("selectAll").checked)
{
isInHouseMemberList = "N";
}
if(document.getElementById("InHouseMember") != null && document.getElementById("InHouseMember").checked)
{
isInHouseMemberList = "Y";
}
//alert(segmentList.substring(0,segmentList.length-1))
var urlParams = "?segmentList="+ segmentList.substring(0,segmentList.length-1) +"&isInHouseMemberList="+ isInHouseMemberList+"&CMSegment="+CMSegment+"&FNOSegment="+FNOSegment+"&CDSSegment="+CDSSegment+"&IPOSegment="+IPOSegment;
var jspWithParams = "getMemberList_XMLHTTP.jsp"+ urlParams;
// window.open(jspWithParams);
submitAsynchronously(segmentList, callbackFunction, jspWithParams);
}
function populateMemberList()
{
var slctMemberList = document.getElementById("memberList");
if (req.readyState == 4)
{
if (req.status == 200)
{
var NeatIdOptionElements = req.responseXML.getElementsByTagName("MemberOption");
// alert(responseXML)
clearDropDownBox(slctMemberList);
//alert(NeatIdOptionElements.length)
for (i = 0; i < NeatIdOptionElements.length; i++)
{
LOVOptionObj = NeatIdOptionElements[i];
LOVOptionTxt = LOVOptionObj.getAttribute("meaning").substring(0,60);
LOVOptionValue = LOVOptionObj.getAttribute("value");
slctMemberList.options[i + 1] = new Option(LOVOptionTxt, LOVOptionValue);
if(!document.getElementById("ExcelId").checked)
slctMemberList.options[i+1].selected = true;
}
}
}
}
function uploadExcel()
{
window.open("uploadMemberList.jsp","ExcelUpload",'resizable=yes,menubar=no,status=yes,titlebar=no,toolbar=no,scrollbars=yes,height=200,width=500,top=100,left=250');
}
//Start: 45 Days Restriction to the reply of the Transactional Alert
function validateDays()
{
var days = 45*(24*60*60*1000);
var newDate =(new Date(new Date() - days));
//alert(newDate);
//alert(sentDateFormatted);
if (newDate > sentDateFormatted){
alert("Reply can only be submitted within 45 days of receiving alert");
return false;
}
else
{
return (validateAdminCommunicationLog());
}
}
//End: 45 Days Restriction to the reply of the Transactional Alert
</script>
</head>
<body class="mainBody" >
<script language="javascript" src="/ENIT/js/communicationLog.js"></script>
<script>
function printDocument()
{
document.all.MainTableDiv.style.overflow = "visible";
window.print();
}
</script>
<form name="communicationLogForm" id="communicationLogForm" method="post" enctype="multipart/form-data" action="communicationLogFileReceiverAdminToMember.jsp" onsubmit="return validateDays();">
<input type="hidden" name="accessType" id="accessType" value=""/>
<input type="hidden" name="logInAs" id="logInAs" value="Member"/>
<input type="hidden" name="replyBy" id="replyBy" value="346"/>
<input type="hidden" name="memId" id="memId" value="346"/>
<!-- Mem Name & mem Code- Added By Smita on 26 Mar 2013 for Investigation Alerts -->
<input type="hidden" name="memName" id="memName" value="ICICI SECURITIES LIMITED"/>
<input type="hidden" name="memCode" id="memCode" value="07730"/>
<input type="hidden" name="reqRefNo" id="reqRefNo" value="EXCHANGE/COMM_LOG/105966"/>
<h4>* Please note that reply for an alert can be submitted only within the 45 days of receiving alert</h4>
<input type="hidden" name="dept" id="dept" value="Investigation"/>
<Div align="center" class="topDiv">
<table>
<tr>
<td class="pageHeadingTd" align="right">
<b>Transactional Alert</b>
</td>
<td class="noBorderTD" align="right" width="60%">
</td>
</tr>
</table>
</div>
<DIV class="mainTableDivStyle" id="MainTableDiv">
<div id="processBar" style="display:none" align="center" class="bottomDiv"><br><br><br><br><br><br>
<img src="../images/progress_bar.gif" border="0"><font color="blue"><b>Processing.....Please Wait.</b></font>
</div>
<table id="mainTable" border=1 class="mainTableStyle">
<tr>
<td width="30%">
<b> Subject : </b>
</td>
<td width="70%">
<input type="hidden" name="subject" id="subject" size="60" maxlength="100" value="Dormant Account"/>
Dormant Account
</td>
</tr>
<tr>
<td width="30%">
<b> Text Message: </b>
</td>
<td width="70%">
<textarea rows="7" cols="100" name="textMessage" id="textMessage" readonly="readonly" ></textarea>
</td>
</tr>
<td>
<b> File Attached : </b>
</td>
<td>
<a href="/ENIT/imsscsv_download.jsp?filename=07730_Dormant_Account_07022019.csv&filepath=/dmsapp/mnt/appln/DMSWeblogic/ENIT_FILES/COMMUNICATION_LOG/SENDER/INVESTIGATION_ALERTS/07730_Dormant_Account_07022019.csv">
07730_Dormant_Account_07022019.csv</a>
</td>
<!--Code to get List of Member's reply-->
<tr >
<td><b>Member Code :</b></td><td> 07730</td>
</tr>
<tr>
<td><b>Member Name :</b></td><td>ABC LIMITED</td>
</tr>
<tr>
<td><b>Reply:</b>
</td>
<td>
<textarea rows="7" cols="50" name="replyTextMessage" id="replyTextMessage"></textarea></td>
</tr>
<tr>
<td><b>File To be Attached : </b></td>
<td>
<input type="file" size="40" id="ReplyFile1" name="ReplyFile1" onkeyup="this.blur()" onkeydown="this.blur()" /> <b>Reply File 1</b><br>
<input type="file" size="40" id="ReplyFile2" name="ReplyFile2" onkeyup="this.blur()" onkeydown="this.blur()" /> <b>Reply File 2</b><br>
<input type="file" size="40" id="ReplyFile2" name="ReplyFile3" onkeyup="this.blur()" onkeydown="this.blur()" /> <b>Reply File 3</b>
</td>
</tr>
<tr>
<td class="noBorderTD" colspan="8">
<b>* Note: </b>Please ensure the size of the attachment is less than 5 MB.
</td>
</tr>
</table>
<DIV class="bottomDiv" align="center">
<input type="submit" value="Submit" />
</div>
</div>
</form>
<script>
function getMemberListFromSession()
{
var memberListCmb = document.getElementById("memberList");
}
</script>
</body>
</html>
一个受保护的站点,显示交易警报。每个警报提供日志文件,每个警报行具有超链接,并且该超链接导航到弹出窗口
Dim IE As New SHDocVw.internetexplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLButtons As MSHTML.IHTMLElementCollection
Dim HTMLButton As MSHTML.IHTMLElement
IE.Visible = True
IE.navigate NSELINK
ShowWindow IE.hwnd, SW_SHOWMAXIMIZED
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Set HTMLDoc = IE.document
HTMLDoc.getElementById("user_id").Focus
HTMLDoc.getElementById("user_id").Value = (NSEUSR)
HTMLDoc.getElementById("member_code").Focus
HTMLDoc.getElementById("member_code").Value = "07730"
HTMLDoc.getElementById("password").Focus
HTMLDoc.getElementById("password").Value = (NSEPWD)
Dim VAL As String
VAL = InputBox("Enter Captcha Value", "CAPTCHA", "")
If VAL = vbNullString Then Exit Sub
HTMLDoc.getElementById("loginCap").Focus
HTMLDoc.getElementById("loginCap").Value = (VAL)
Application.Wait (Now + TimeValue("00:00:04"))
HTMLDoc.getElementById("user_id").Focus
Application.Wait (Now + TimeValue("00:00:10"))
HTMLDoc.getElementById("ext-gen39").Focus
HTMLDoc.getElementById("ext-gen39").Click
While IE.readyState <> 4: DoEvents: Wend
Application.Wait (Now + TimeValue("00:00:05"))
HTMLDoc.getElementById("btn_Skip").Click
While IE.readyState <> 4: DoEvents: Wend
Application.Wait (Now + TimeValue("00:00:05"))
HTMLDoc.getElementById("ext-gen20").Focus
HTMLDoc.getElementById("ext-gen20").Click
While IE.readyState <> 4: DoEvents: Wend
Application.Wait (Now + TimeValue("00:00:10"))
HTMLDoc.querySelector("[tabindex='1']").Click
Application.Wait (Now + TimeValue("00:00:10"))
IE.navigate NSELINK2
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Application.Wait (Now + TimeValue("00:00:01"))
HTMLDoc.getElementById("communicationLogFilterFrame").contentWindow.document.getElementById("communicationType").Value = "EXCHANGE_TO_MEMBER"
Application.Wait (Now + TimeValue("00:00:01"))
HTMLDoc.getElementById("communicationLogFilterFrame").contentWindow.document.getElementById("txtFromDate").Value = (LD)
Application.Wait (Now + TimeValue("00:00:01"))
HTMLDoc.getElementById("communicationLogFilterFrame").contentWindow.document.getElementById("txtToDate").Value = (LD)
Application.Wait (Now + TimeValue("00:00:01"))
HTMLDoc.getElementById("communicationLogFilterFrame").contentWindow.document.getElementById("search").Click
Application.Wait (Now + TimeValue("00:00:01"))
弹出窗口中必需的Href值
答案 0 :(得分:0)
取决于您是否具有该窗口句柄。如果您这样做,那就很简单:
ie.document.querySelector("a[href]").href
如果没有,请检查此href
值是否在预弹出窗口的其他位置存在。否则,您将需要循环并首先找到此窗口。例如,您也许可以改编this。