Home > Web Front-end > HTML Tutorial > Read the onclick attribute value of the page element, prohibit redirection, and obtain the redirection target specified by the Location header after url redirection_html/css_WEB-ITnose

Read the onclick attribute value of the page element, prohibit redirection, and obtain the redirection target specified by the Location header after url redirection_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:04:18
Original
1457 people have browsed it

(1) Read the onclick attribute value of the page element

html code:

Link

Get the value of the onclick attribute on the item: alert('ok');
Implementation:

IHTMLElement *item;// 已经找到该元素CComQIPtr<IHTMLElement> spElem(item);VARIANT var;spElem->get_onclick(&var);CComQIPtr<IDispatch> spDisp(var.pdispVal);DISPID dispId = 0;OLECHAR *szName = L"toString";spDisp->GetIDsOfNames(IID_NULL, &szName, 1, LOCALE_SYSTEM_DEFAULT, &dispId);DISPPARAMS params;memset(¶ms, 0, sizeof(params));VARIANT varRet;spDisp->Invoke(dispId, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, ¶ms, &varRet, NULL, NULL);CString k= CString(varRet.bstrVal);
Copy after login

(2) Disable redirection and obtain the redirection target specified by the Location header after url redirection

Disable redirection with INTERNET_FLAG_NO_AUTO_REDIRECT

DWORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII|INTERNET_FLAG_NO_AUTO_REDIRECT;

cFile = (CHttpFile*)Sess.OpenURL(url,1,dwFlags);


Get the redirection target specified by the Location header after url redirection

CString cstrLocation;


cFile ->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, cstrLocation);


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template