我正在尝试编写一个vba代码,在登录后自动点击图标链接。我坚持使用下面编写的vba代码,当我运行vba宏时没有响应。我相信图标链接在网页的框架内。请帮助谢谢
我尝试右键单击图标链接以检查框架网址,并在登录后导航到该网页,但它会自动重定向到我不想要的其他网页。
网址(带有图标链接的目标网页):“https://trading.poems.com.hk/poems2/poems.asp?func=view”
自动重定向网页:“https://trading.poems.com.hk/poems2/loginaction.asp”
图标链接html代码:
<a href="#" onClick="StockPop = window.open ('http://www.poems.com.hk/stockSummary/stockSummary.asp? iKey=2755766c747a25535353574373b375a375c05','StockAnalytics','scrollbars=yes,resizable=yes,status=yes,left=0,top=0,width=1250,height=700,toolbar=0')"><img src="images/Corner/EN/Company.png" border=0 title="Stock Analytics "></a>
我的VBA代码:
Sub open3()
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "https://trading.poems.com.hk/poems2/poems.asp?func=view"
Do Until ie.readyState = 4
DoEvents
Loop
For Each ele In ie.document.getElementsByTagName("a")
If InStr(ele.innerHTML, "images/Corner/EN/Company.png") > 0 Then
ele.Click
Exit For
End If
Next
End Sub
网页的框架:
<html>
<head>
<title>Phillip Securities (HK)-?????? (?????????)</title>
<link rel="shortcut icon" href="images/phillip.ico">
<meta http-equiv="Content-Type" content="text/html; charset=big5"></head>
<frameset cols="*, 100%" border=0 frameborder=0 framespacing=0 marginheight=0 marginwidth=0>
<frame src="Poems2/BrowserChecking.asp" name="ChkBrowser">
<frame src="Poems2/Poems.asp" name="login" frameborder=0 framespacing=0 marginheight=0 marginwidth=0>
</frameset><noframes></noframes>
</html>
HTML源代码的一部分:
<!DOCTYPE html PUBLIC "-/W3C//DTD XHTML 1.0 Transtitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>??????-?????????</title>
</head>
<link href="css/phillip.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" >document.domain="poems.com.hk"</script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu_Execution_EN.css" />
<script type='text/javascript' src='js/ddsmoothmenu.js'></script>
<script type="text/javascript" src="js/font.js"></script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
<script type="text/javascript">
var myclose = false;
function ConfirmClose()
{
frameURL = (parent.DetailFrame.location.href).toUpperCase()
//alert(frameURL + "//// " + frameURL.indexOf("PPSHK.COM"))
if (frameURL.indexOf("PPSHK") > 0)
{
if (event.clientY < 0)
{
event.returnValue = '???????????, ?????????\n????!';
//setTimeout('myclose=false',10000);
//myclose=true;
}
}
}
function parentExists() {
return (parent.location == window.location) ? false : true;
}
if(!parentExists())
document.location = "../index2.htm"
function checkKeyCode(evt)
{
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if(event.keyCode==116)
{
location.reload(true);
return false
}
}
document.onkeydown=checkKeyCode;
</script>
<body onUnload="CloseAllPop()">
<script>
var EFuturePop
var StockPop
var USStockPop
var SGStockPop
var JPStockPop
var SAStockPop
var SOptionPop
var SNOptionPop
var StockGTCPop
var BullionPop
var FxBannerPop
var FoFuturePop
var ForexPop
var FoOptionsPop
var ForexResponse
var FoFutureResponse
var FoOptionsResponse
function CloseAllPop(){
if(EFuturePop != null){
EFuturePop.close()
}
if(StockPop != null){
StockPop.close()
}
if(USStockPop != null){
USStockPop.close()
}
if(SGStockPop != null){
SGStockPop.close()
}
if(JPStockPop != null){
JPStockPop.close()
}
if(SAStockPop != null){
SAStockPop.close()
}
if(SOptionPop != null){
SOptionPop.close()
}
if(SNOptionPop != null){
SNOptionPop.close()
}
if(StockGTCPop != null){
StockGTCPop.close()
}
if(BullionPop != null){
BullionPop.close()
}
// if(FxBannerPop != null){
// FxBannerPop.close()
// }
if(FoFuturePop != null){
FoFuturePop.close()
}
if(ForexPop != null){
ForexPop.close()
}
if (FoOptionsPop != null) {
FoOptionsPop.close()
}
}
function forexClose(ans){
ForexResponse = ans;
}
function foFutureClose(ans){
FoFutureResponse = ans;
}
function foOptionsClose(ans) {
FoOptionsResponse = ans;
}
function DisclaimerClose(type,ans){
if (type == "Forex"){
ForexResponse = ans;
}
else if (type == "FoFuture"){
FoFutureResponse = ans;
}
else if (type == "FoOptions") {
FoOptionsResponse = ans;
}
}
function changeDetailFrame(link) {
$('#DetailFrame').attr('src',link);
}
function CheckStockGTCPop(){
if(StockGTCPop != null){
parent.DetailFrame.location.href = "NoPopup/ZH/TradeStock_GTC.asp"
}
else{
StockGTCPop = window.open('StockDisclaimer_GTC.asp','HKStockGTC','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
function CheckForexPop(){
if (ForexResponse=="A"){
if (ForexPop.closed) {
ForexPop = window.open('Forex/asp/menu/100kforex_fr.asp','Forex','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
else{
ForexPop = window.open('ForexDisclaimer.asp','Forex','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
function CheckFoFuturePop(){
if (FoFutureResponse=="A"){
if (FoFuturePop.closed){
FoFuturePop = window.open('FoFutures/EN/ftslingshot2b3/LiveMain_fr.asp?type=F', 'FoFuture', 'scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
else{
FoFuturePop = window.open('FoFutureDisclaimer.asp','FoFuture','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
function CheckFoOptionsPop() {
if (FoOptionsResponse == "A") {
if (FoOptionsPop.closed) {
FoOptionsPop = window.open('FoFutures/EN/ftslingshot2b3/LiveMain_fr.asp?type=O', 'FoFuture', 'scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
else {
FoOptionsPop = window.open('FoOptionsDisclaimer.asp','FoOptions', 'scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
}
}
// function CheckFoFuturePop_FO(){
// FoFuturePop = window.open('FoFutures/EN/ftslingshot2b3/LiveMain_fr_FO.asp','FoFuture','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=1014,height=710,toolbar=0')
// }
function CheckFxBannerPop(){
if(FxBannerPop != null){
parent.DetailFrame.location.href = "Forex/asp/menu/100kforex_fr.asp"
}
else{
parent.DetailFrame.location.href = "Forex/asp/menu/100kforex_fr.asp"
FxBannerPop = window.open('Banner.htm','FxBanner','scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=600,height=300,toolbar=0')
}
}
//document.body.onunload = CloseAllPop
</script>
<table width="985" border="0" align="center" cellpadding="0" cellspacing="0" id="maintable">
<tr>
<td width="10" background="images/bgsquareleft.jpg"></td>
<td bgcolor="#FFFFFF"><table width="940" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="64"><a href="MainMenu.asp" target="DetailFrame"><img src="POEMSBanner.gif" alt="Phillip's ON-LINE ELECTRONIC MART SYSTEM" height="54" border="0" /></a></td>
<td align="right" valign="bottom" class="style3">
<a href="#" onClick="TradCenPop = window.open('https://trading.poems.com.hk/Poems2/tradingcentral/index.aspx?pf=X&lang=en&id=XXXXXX','TradingCentral','scrollbars=yes,resizable=yes,status=yes,left=0,top=0,width=680,height=480,toolbar=0')"><img src="images/Corner/EN/tradingcen.png" border=0 title="Trading Central"></a>
<a href="#" onClick="StockPop = window.open('http://www.poems.com.hk/stockSummary/stockSummary.asp?iKey=2755766c747a4373b375a375c05','StockAnalytics','scrollbars=yes,resizable=yes,status=yes,left=0,top=0,width=1250,height=700,toolbar=0')"><img src="images/Corner/EN/Company.png" border=0 title="Stock Analytics "></a>&>
答案 0 :(得分:0)
您的网址“https://trading.poems.com.hk/poems2/poems.asp?func=view”会返回没有单个标记的框架集页面的HTML代码。
请注意,Browser对象中的Document元素不会展开底层页面。您可以在此处看到与使用“show source”功能
在浏览器中相同的内容检查直接调用(其中一个)框架页面的可能性