【问题已解决】_IEGetObjByName怎么获取IE中的按钮对象??
本帖最后由 killmus 于 2010-7-15 15:13 编辑#include <IE.au3>
$eyoo = _IECreate ("http://www.e-yoo.cn/ybd/form2?id=875&keepThis=true&TB_iframe=true&height=190&width=430")
$gzc = _IEGetObjByName ($eyoo,"name")
_IEFormElementSetValue ($gzc,"小明")
$gzc = _IEGetObjByName ($eyoo,"tel")
_IEFormElementSetValue ($gzc,"13837655789")
$gzc = _IEGetObjByName ($eyoo,"qq")
_IEFormElementSetValue ($gzc,"286478259")
$forms = _IEGetObjByName ($eyoo,"我要投票")-----------------------就是这个搞不懂啊。就是不点击,大家帮帮小弟吧!
_IEAction ($forms,"click")
如上图,我就是想获取图中的“我要投票”对象,然后点击它。
以下是IE页面的源码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="/ztwb/library/thickbox.css" rel="stylesheet" type="text/css" />
<link href="/ztwb/library/form2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/ztwb/library/js/jquery.min.js"></script>
<script type="text/javascript" src="/ztwb/library/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/ztwb/library/js/blur.js"></script>
<script type="text/javascript" src="/ztwb/library/js/Validate.js"></script>
<script type="text/javascript">
var tb_pathToImage = "/ztwb/images/thickbox.gif";
$(document).ready(function(){
$('form').submit(function(){
var isform = Validator.Validate(this, 3);
if (!isform) return false;
$.cookie('vote_name', $('#name').val(), 1);
$.cookie('vote_tel', $('#tel').val(), 1);
$.cookie('vote_qq', $('#qq').val(), 1);
$('.btn_tp').attr('disabled' , true);
});
$('.btn_tp').click(function(){
$('form').submit();
return false;
})
if ($.cookie('vote_name')) {
$('#name').val($.cookie('vote_name'));
$('#tel').val($.cookie('vote_tel'));
$('#qq').val($.cookie('vote_qq'));
$('form').submit();
}
});
</script>
<style>
body,html {
background:#FFFFFF none;
}
</style>
<title>我要投票</title>
</head>
<body>
<div class="form">
<form action="/ybd/votesave" method="post">
<ul>
<li>填写以下信息,为喜爱的网吧投上一票,还可参加幸运大抽奖!</li>
<li>姓 名:
<input name="name" id="name" msg="请填写真实姓名" datatype="Require" type="text" /> <span>*</span>
</li>
<li>联系方式:
<input name="tel" type="text" id="tel" datatype="Require" msg="请正确填写联系方式" /> <span>*</span>
</li>
<li>Q Q 号码:
<input name="qq" type="text" id="qq" datatype="Number" msg="请正确填写QQ号码"/> <span>*</span>
<input type="hidden" name="id" value="875">
</li>
</ul>
</form>
<div><a href="我要投票" class="btn_tp">我要投票</a></div>
</div>
</body>
</html> 本帖最后由 netegg 于 2010-7-11 18:33 编辑
谁说那个是按钮了,用枚举元素那个函数看看 回复 2# netegg
谢谢,我试试 回复 3# killmus
我不会弄,谁能帮我写一上吗?先谢谢了 <form action="/ybd/votesave" method="post">
表单提交或post提交应该都可行的
后者速度更快
别老盯着那个按钮找解决办法
换换思路就行了#include <IE.au3>
$eyoo = _IECreate ("http://www.e-yoo.cn/ybd/form2?id=875&keepThis=true&TB_iframe=true&height=190&width=430")
$gzc = _IEGetObjByName ($eyoo,"name")
_IEFormElementSetValue ($gzc,"小明")
$gzc = _IEGetObjByName ($eyoo,"tel")
_IEFormElementSetValue ($gzc,"13837655789")
$gzc = _IEGetObjByName ($eyoo,"qq")
_IEFormElementSetValue ($gzc,"286478259")
$oForms = _IEFormGetCollection ($eyoo )
For $oForm In $oForms
_IEFormSubmit ($oForm)
Next 本帖最后由 lynfr8 于 2010-7-14 17:36 编辑
http://www.autoitx.com/thread-16868-1-1.html
真是巧,和这个问题性质是一样的!
第二种表单提交解决方法:
#include <IE.au3>
$eyoo = _IECreate ("http://www.e-yoo.cn/ybd/form2?id=875&keepThis=true&TB_iframe=true&height=190&width=430")
$gzc = _IEGetObjByName ($eyoo,"name")
_IEFormElementSetValue ($gzc,"小明")
$gzc = _IEGetObjByName ($eyoo,"tel")
_IEFormElementSetValue ($gzc,"13837655789")
$gzc = _IEGetObjByName ($eyoo,"qq")
_IEFormElementSetValue ($gzc,"286478259")
$oForms = _IEFormGetCollection ($eyoo )
$eyoo.document.forms(0).submit() 非常感谢,各位元老的帮忙,小弟今后一定认真学习AU3{:face (411):} 非常感谢,各位元老的帮忙,小弟今后一定认真学习AU3{:face (411):} 非常好的代码 不错啊是不是 嘿嘿,最近正好研究网页呢
页:
[1]