摘要:// This goes past the ATL includes#import "C:/WINDOWS/system32/Macromed/Flash/Flash9e.ocx" named_guids, rename_namespace("Flash")Flash::IShockwaveFlash * flash = NULL; hr = spDispatch->QueryInterface(__uuidof(Flash::IShockwaveFlash), (void **) &flash);flash->GetVariable
阅读全文
随笔分类 - 浏览器编程
IE,FF,Chrome
摘要:<= IE6:IE6 下如果iframe很多,子框架的BeforeNavigate2,DownloadBegin,DownloadComplete,DocumentComplete可能交替出现打开新网页刷新现有页面主窗口 BeforeNavigate2 (top most)主窗口 DownloadBegin (top most)主窗口 DownloadComplete(top most)主窗口DownloadBegin (top most)主窗口DownloadComplete(top most)主窗口 DownloadBegin (top most)主窗口 NavigateComple
阅读全文
摘要:枚举所有iframe的IWebBrowser2// Get the IDispatch of the document.//LPDISPATCH lpDisp = NULL;lpDisp = m_webBrowser.GetDocument();if (lpDisp){ IOleContainer* pContainer; // Get the container. // HRESULT hr = lpDisp->QueryInterface(IID_IOleContainer, (void**)&pC...
阅读全文
摘要:js中调用console写日志console.log("some log");console.warn("some warning");console.error("some error");IE:只有在打开IE开发者工具后才能使用console,默认访问IE的console对象会出错。FF和Chrome没有问题。
阅读全文
摘要:// BHO 中添加下面的函数,设置UIHandler// BHO 包含如下成员变量:// CDocDispatch m_docDispatch;// CComPtr<IDocHostUIHandler> m_spDefaultDocHostUIHandler;// CComPtr<IOleCommandTarget> m_spDefaultOleCommandTarget;HRESULT CBHO::SetDocHostUIHandler(IDispatch *pWebBrowser){ HRESULT hr = S_OK; if(NULL == pWebBrowse
阅读全文
摘要:往一个空的iframe中写入内容,再其document ready之前有可能遇到拿回 的body指针为空,因此以下面的函数往其document中写入htmlHRESULT WriteToHtmlDocument(CComPtr<IHTMLDocument2> spDoc2, CComBSTR &bstrHtml){ HRESULT hr = S_OK; //BSTR bstr = SysAllocString(OLESTR("Written by IHTMLDocument2::write().")); BSTR bstr = bstrHtml.Copy
阅读全文
摘要:获得iframe标签的元素指针CComPtr spAdIframe = ...CComQIPtr spFrameBase2 = spAdIframe;CComPtr spIframeWindow2 = NULL; hr = spFrameBase2->get_contentWindow(&spIframeWindow2);由此可得到iframe元素对应的IHTMLWindow2指针,然而如果直接使用IHTMLWindow2::get_document来获取IHTMLDocument2指针的话,经常得到的是E_ACCESSDENIED错误,因为iframe元素经常用于跨域的访问,即
阅读全文
摘要:js脚本是按其出现在文档中的顺序执行的。<script> tag的内容总是在被解析到的时候被js引擎解释,所以最后一个script tag总是当前正在解析的script tag, sample如下:<div><script> var scriptTag = document.getElementsByTagName('script'); scriptTag = scriptTag[scriptTag.length -1]; var parent = scriptTag.parentNode;</script></div>
阅读全文
摘要:调用IHTMLElement::insertAdjacentHTML插入HTMLvirtual /* [id] */ HRESULT STDMETHODCALLTYPE insertAdjacentHTML( /* [in] */ __RPC__in BSTR where, /* [in] */ __RPC__in BSTR html) = 0;可用的where:beforeBeginafterBeginbeforeEndafterEnd特别要注意,当插入的html包含script标签的时候,需要在script标签之前添加其他的text或者tag,...
阅读全文
浙公网安备 33010602011771号