3,245
社区成员
发帖
与我相关
我的任务
分享
function check_login()
{
var a = "1";
if(document.f.p_pass.value != "" && document.f.login_name.value != "")
{
if(document.f.login_mode.value == 1 && document.f.login_name.value == "cvr_admin")
{
alert("nvr_admin没有DVR登陆模式!");
} else if(a != 1 && document.f.login_name.value == "nvr_admin"){
alert("您的输入有误(不能用CVR用户登陆)");
// doFireEvent(document.getElementById("login_dynamic"), "click");
}else {
doFireEvent(document.getElementById("login_dynamic"), "click");
}
}
else
{
alert("您的输入有误(用户名或密码不能为空)");
}
}
代码是这样的 怎么处理呢?
HRESULT hr;
LPUNKNOWN lpUnknown;
LPUNKNOWN lpUnknownWB = NULL;
LPUNKNOWN lpUnknownDC = NULL;
IHTMLElementCollection *objAllElement=NULL;
IHTMLDocument2 *objDocument=NULL;
CString strUrl,strTemp;
lpUnknown = m_web.GetControlUnknown();
ASSERT(lpUnknown);
if (lpUnknown)
{
hr = lpUnknown->QueryInterface(IID_IUnknown,(LPVOID*)&lpUnknownWB);
ASSERT(SUCCEEDED(hr));
if (FAILED(hr))
return;
hr = pDisp->QueryInterface(IID_IUnknown, (LPVOID*)&lpUnknownDC);
ASSERT(SUCCEEDED(hr));
if (SUCCEEDED(hr) && lpUnknownWB == lpUnknownDC)
{
// The document has finished loading.
strUrl=m_web.get_LocationURL();
if (strUrl.IsEmpty())
{
return ;
}
objDocument=(IHTMLDocument2*)m_web.get_Document();
objDocument->get_all(&objAllElement);
if (strUrl==_T("https://43.4.213.11:2004/"))
{
CComPtr<IDispatch>pDisp;
objAllElement->item(COleVariant(_T("p_pass")),COleVariant((long)0),&pDisp);
CComQIPtr<IHTMLElement, &IID_IHTMLElement>pElement;
if(pDisp==NULL)
{
return;
}
else
{
pElement=pDisp;
pElement->put_innerText(_T("123")); //填充表单
}
VARIANT name;
CComBSTR tag;
long index;
objAllElement-> get_length(&index);
name.vt=VT_I4;
for(long i=0; i <index; i++)//遍历所有元素,通过id属性获取值
{
name.lVal = i;
IDispatch * pDispatch=NULL;
objAllElement-> item(name,name,&pDispatch);
IHTMLElement* spElement;
pDispatch-> QueryInterface(IID_IHTMLElement, (void**)&spElement);
BSTR tag;
spElement->get_className(&tag);
CString ss(tag);
if(ss == "login-btn-01")
{
spElement->click();
MessageBox(_T("Sucess!"));
}
spElement->Release();
}
}
}
}
if (lpUnknownWB)
lpUnknownWB->Release();
if (lpUnknownDC)
lpUnknownDC->Release();