Jump to content

How can I use the UDF to click a link?


 Share

Recommended Posts

The following is the code of the page I am gonna click, how can I use the UDF _IELinkClickByText or _IELinkClickByIndex to click the link:

<a id="menu_createAsset" title='网上刷卡' onclick="SentParm('1','1','1')"

you can search the text in the following codebox, thanks a lot.

ps: I'm sorry for that the page is Chinese, and I do not translate it into English.

I made the link I wanna clink to bold and the color is blue :)

here is the page:

CODE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>首页 </title>

<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">

<meta name="CODE_LANGUAGE" Content="C#">

<meta name="vs_defaultClientScript" content="Javascript">

<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

<LINK href="/atm/css/cssCn.css" type="text/css" rel="stylesheet">

<script src="../../Js/common.js"></script>

<script language="javascript">

function RediectURL(url)

{

window.location = url;

}

top.frames['mainFrameSet'].cols = '10,67';

var PrevSelectedValue = 1; // 默认显示的菜单项编号

function showMenu(ShowValue, index, subIndex, url)

{

PrevSelectedValue = top.topframe.document.getElementsByName("PrevSelectedValue")[0].value;

var LinkValu='';

var strValue='';

window.status = "正在切换功能模块,请稍候......";

if (ShowValue == "99")

{

LinkValue = PrevSelectedValue; //增加刷新功能,胡成龙, 2004-6-9

}

else

{

LinkValue = ShowValue;

}

if (PrevSelectedValue != LinkValue)

{

var trs = top.topframe.document.getElementsByTagName("td");

var i ;

//清除以前的选中显示

strValue = "tdmenu" + PrevSelectedValue;

top.topframe.document.getElementById(strValue).className = "tab";

for(i=0;i <trs.length;i++)

{

if( trs.item(i).id == strValue )

{

if(trs.item(i-1).id=="td_vline")

{

trs.item(i-1).className = "vline";

}

trs.item(i+1).className = "vline";

}

}

strValue = "linkmenu" + PrevSelectedValue;

//高亮当前的显示

strValue = "tdmenu" + LinkValue;

top.topframe.document.getElementById(strValue).className = "active";

for(i=0;i <trs.length;i++)

{

if( trs.item(i).id == strValue )

{

trs.item(i-1).className = "";

trs.item(i+1).className = "";

}

}

strValue = "linkmenu" + LinkValue;

PrevSelectedValue = LinkValue;

top.topframe.document.getElementsByName("PrevSelectedValue")[0].value=LinkValue;

}

//显示POPUP window

//window.parent.leftup.ShowPOPUP();

// 处理左菜单与欢迎页

top.frames['mainFrameSet'].cols = '10,67';

top.leftup.location.href="/ATM/ZteMenu/OutLook/index/FrameLeftMenu.aspx?isExpand=1&parentMenuKey=" + ShowValue + "&itemId=" + index + "&subItemId=" + subIndex + "&url=" + url;

if (url != "" && !(url.indexOf('#')>=0))

{

top.right.location.href= "/ATM" + url;

}

//焦点集中

parent.rightup.window.focus();

}

</SCRIPT>

<script>

function openpopup()

{

url="/ATM/ZteMenu/OutLook/index/version.aspx"

window.open(url,"说明","width=500,left=" + (screen.width-540)/2 + ",height=500,top=" + (screen.height-370)/2)

}

function SentParm(sTopmenuID,sMenuID,sSubMenuID)

{

document.all.topcmd.src = "index/FrameTopCmd.aspx?sTopmenuID="+sTopmenuID+"&sMenuID=" + sMenuID +"&sSubMenuID="+sSubMenuID;

}

</script>

</HEAD>

<body id="thebody" MS_POSITIONING="GridLayout">

<iframe id="topcmd" src="" width="0" height="0"></iframe>

<form name="Form1" method="post" action="FirstPage.aspx?oneName=%E4%B8%8E%E6%88%91%E6%9C%89%E5%85%B3-%E6%88%91%E7%9A%84%E8%80%83%E5%8B%A4-%E6%88%91%E7%9A%84%E9%A6%96%E9%A1%B5" id="Form1">

<input type="hidden" name="__VIEWSTATE" value="dDwxNzMxOTAzNTgwOzs+x6FwtCclUAHrQ7i7zyYrCIiXKlU=" />

<FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体">

</FONT><FONT face="宋体"></FONT>

<br>

<table width="98%" border="0" align="center" cellPadding="0" cellSpacing="0" id="tb_content">

<tr>

<td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#abbde3">

<tr>

<td bgcolor="#f7f9fe">

<TABLE border="0" cellPadding="0" cellSpacing="0" bgcolor="#6280b8">

<TBODY>

<TR valign="bottom" id='trtab1'>

<TD bgcolor="#d2e1fd"><DIV align="center"><FONT color="#0000cc"> 常用功能</FONT> </DIV>

</TD>

</TR>

</TBODY>

</TABLE>

<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">

<TBODY>

<TR>

<TD bgColor="#d2e1fd"><img src="../images/levinarrow.gif" width="1" height="6"></TD>

</TR>

</TBODY>

</TABLE>

</td>

</tr>

<tr>

<TD bgColor="#ffffff"><table cellspacing="8" cellpadding="3" width="96%" align="center" border="0" id="trdis1">

<tbody>

<tr>

<td width="15%"><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_myTask" title='我的考勤' onclick="SentParm('1','1','64')"

href="#">我的考勤</a></td>

<td width="15%"><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_createAsset" title='网上刷卡' onclick="SentParm('1','1','1')"

href="#">网上刷卡</a></td>

<td width="15%"><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_createExperience" title='刷卡记录' onclick="SentParm('1','1','2')"

href="#">刷卡记录</a></td>

<td width="15%"><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_createAdvice" title='我的加班' onclick="SentParm('1','1','3')"

href="#">我的加班</a></td>

</tr>

<tr>

<td><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_sortBrowse" title='加班申请' onclick="SentParm('1','5','7')"

href="#">加班申请</a></td>

<td><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_advanceQuery" title='请假申请' onclick="SentParm('1','6','11')"

href="#">请假申请</a></td>

<td><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_browseView" title='出差申请' onclick="SentParm('1','7','18')"

href="#">出差申请</a></td>

<td><img src="../../images/levinarrow.gif" width="9" height="9" class="icon1"><a id="menu_graphNavigation" title='补单申请' onclick="SentParm('1','10','30')"

href="#">补单申请</a></td>

</tr>

</tbody>

</table>

</TD>

</tr>

</table>

</td>

</tr>

<tr>

<td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><br>

<table width="100%" align="center" cellpadding="0" cellspacing="0">

<tr>

<td height="22" onclick="ShowDataList('11');" style='BORDER-RIGHT:#ffffff 1px solid; BORDER-TOP:#ffffff 1px solid; BORDER-LEFT:#ffffff 1px solid; CURSOR:hand; BORDER-BOTTOM:#ffffff 1px solid'

onmouseover="this.style.backgroundColor='ECF6FF';this.style.borderColor='93B8DF';"

onmouseout="this.style.borderColor='#ffffff';this.style.backgroundColor='#ffffff';"><img src="../../images/arrow_down.gif" class="icon1" id="Img11">功能描述</td>

</tr>

<tr id="Table11">

<td><hr width="99%">

<table width="99%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><h6 class="style3">与我有关:

</h6>

<ul>

<!--li>集中展示用户需要进行处理的内容,包括与我有关、数据处理、项目配置三个模块。</li-->

<li>与我有关,提供我的考勤、网上刷卡、刷卡记录的查询、我的加班功能模块;</li>

<li>我的申请,提供我的加班申请、请假申请、出差申请、补单申请、调休申请的快捷方式;</li>

<li>我的审批,提供与我有关的业务逻辑上的审批。</li>

</ul>

<h6>考勤业务:

</h6>

<ul>

<!--li>对研发过程中的数据进行度量和展示,包括关注点、指示器、状态报告、能力基线四个模块。</li-->

<li>业务审批,提供业务逻辑的的审批;</li>

<li>加班管理,提供加班申请、指定加班及加班统计等功能;</li>

<li>请假管理,提供请假申请、指定请假及请假统计等功能;</li>

<li>出差管理,提供出差申请、指定出差及出差统计等功能;</li>

<li>调休管理,提供调休申请、指定加班及调休统计等功能;</li>

<li>倒班管理,提供指定倒班及倒班查询的功能;</li>

<li>补单管理,提供补单申请、我的补单及补单查询等功能;</li>

<li>分组考勤,提供分组设置、考勤查询等功能。</li>

</ul>

<h6>考勤设置:

</h6>

<ul>

<li>考勤数据提供人员、部门、班组、班次、考勤地点等基础数据参数的配置;</li>

<li>考勤方案提供考勤方案的设置及应用的功能;</li>

<li>考勤卡设置提供考勤的注册及统计的功能;</li>

<li>倒班设置提供倒班班组及班次的配置功能;</li>

<li>其他设置提供强制全勤、自动考勤的功能。</li>

</ul>

<h6>

考勤报表:</h6>

<ul>

<!--li>PDB系统管理模块,包括权限管理、辅助管理和系统工具三个模块。</li-->

<li>统计查询、提供今日考勤、统计查询、考勤统计、考勤查询等多项统计;</li>

<li>考勤报表、考勤统计生成报表。</li>

</ul>

<h6>系统管理:</h6>

<ul>

<!--li>PDB系统管理模块,终端管理两个模块。</li-->

<li>系统管理提供角色、群组、角色权限的管理;</li>

<li>终端管理,提供运行状态、错误报告、处理查询等功能。</li>

</ul>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</form>

</body>

</HTML>

Edited by chenxu
Link to comment
Share on other sites

The following is the code of the page I am gonna click, how can I use the UDF _IELinkClickByText or _IELinkClickByIndex to click the link:

<a id="menu_createAsset" title='网上刷卡' onclick="SentParm('1','1','1')"

you can search the text in the following codebox, thanks a lot.

ps: I'm sorry for that the page is Chinese, and I do not translate it into English.

I made the link I wanna clink to bold and the color is blue :)

You could try something like this:

#include <IE.au3>

$sURL = "http://www.???.???"
$oIE = _IECreate($sURL)
$colLinks = _IELinkGetCollection($oIE)
For $oLink in $colLinks
    If $oLink.id = "menu_createAsset" Then
        _IEAction($oLink, "click")
        ExitLoop
    Next
Next
_IELoadWait($oIE)

But I can't test, and it may require an iFrame/Form reference before searching the links.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...