***200分,如何取得链接所属的网页url和该链接名称?****

myb123 2003-12-12 01:29:21
在FlashGet中可以做到,从IE中拖一个链接到FlashGet中,它能取得该链接所指向的url,
还能取到引用Referer(即该链接所属网页的url,例http://www.xxx//xxx.html),和能取到注释Comment(即该链接的名称,例如'点这里下载-> 本地下载')

而我用了网上某个类只能取到链接所指向的url,
请教,不知如何才能取得链接所属的网页url和该链接名称?
...全文
161 11 打赏 收藏 举报
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
myb123 2003-12-13
谢谢
to jiangsheng(蒋晟.Net)
能贴点程序吗,我看不懂哎.
to yintongshun(踏雪有痕)
FlashGet在myie中也能取得链接所属的网页url和该链接名称,而myie的主窗口并不是IEFrame
  • 打赏
  • 举报
回复
myb123 2003-12-13
up
  • 打赏
  • 举报
回复
philis 2003-12-12
楼上的大哥,你贴的东西我找了好久都没找到,多谢了。
  • 打赏
  • 举报
回复
yintongshun 2003-12-12
让应用程序从IE中获取键入的网址
HWND hwnd=::FindWindow(_T("IEFrame"),NULL);
 if(hwnd)
 {
   HWND hwnd2=::FindWindowEx(hwnd,NULL,_T("Edit"),NULL);


char sz[255];
::SendMessage(hwnd2,WM_GETTEXT,255,(LPARAM)sz);
AfxMessageBox(sz);
 }

结果发现不能得到正确的结果,从SPY上看,类名也全部是正确的,为什么不能得到正确的结果呢?看了他的代码后,我进行了如下改动,就可以得到正确的结果了:

HWND hwnd=::FindWindow(_T("IEFrame"),NULL);
if(hwnd)
{
HWND hwnd2=::FindWindowEx(hwnd,NULL,_T("WorkerW"),NULL);
HWND hwnd3=::FindWindowEx(hwnd2,NULL,_T("ReBarWindow32"),NULL);
HWND hwnd4=::FindWindowEx(hwnd3,NULL,_T("ComboBoxEx32"),NULL);
HWND hwnd5=::FindWindowEx(hwnd4,NULL,_T("ComboBox"),NULL);
HWND hwnd6=::FindWindowEx(hwnd5,NULL,_T("Edit"),NULL);

char sz[255];
::SendMessage(hwnd6,WM_GETTEXT,255,(LPARAM)sz);
AfxMessageBox(sz);
}
}

下面是相关的:
IE编程技巧1.实现Ctrl+C:
ExecWB(OLECMDID_COPY,OLECMDEXECOPT_DONTPROMPTUSER,NULL,NULL);

2.实现Ctrl+V:

ExecWB(OLECMDID_PASTE,OLECMDEXECOPT_DONTPROMPTUSER,NULL,NULL);

3.实现查找:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_FIND,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

4.实现显示源程序:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_VIEWSOURCE,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

5.实现显示Internet选项:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_OPTIONS,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

6.下载事件说明:

OnDownloadBegin <--开始下载
OnDownloadComplete <--下载结束
OnDocumentComplete <--页面下载完毕

对于每个HTML页面,顺序都是如此.如果是Frame或IFrame的文件都会当成HTML页面处理.也就是说如果一个页面中有3个IFrame,那么总共会触发4次BeforeNavigate2事件.

对于每个连接且需要显示出来的二进制文件(如*.gif,*.bmp,*.jpg...)都会触发一个DownloadBegin和DownloadComplete事件.

那我们怎么判断是否全部下载完毕呢?嘿嘿,TWebBrowser控件不是有一个Busy属性的吗?

7.点击链接产生的事件:

OnBeforeNavigate2 <--开始链接时会触发此事件
OnNavigateComplete2 <--成功的链接到此网页(以后才会有上面的事件)


8.包括相关文件:

#include <mshtmhst.h>
#include <mshtmcid.h>//这里面有很多实现IE功能的XXID,请看一看!
#import <mshtml.tlb>





  • 打赏
  • 举报
回复
蒋晟 2003-12-12
The hyperlink object
A hyperlink object implements the IHlink interface and encapsulates four pieces of reference information: a moniker to the hyperlink target; a string for the location within the target; a friendly name for the target; and additional parameters.

The hyperlink object completely encapsulates the behavior of navigating to a referenced location. It also supports the ability to save and load itself through the IPersistStream interface, and the ability to be transferred through the clipboard or through drag-and-drop operations by means of IDataObject. A standard hyperlink object implementation is provided with the system, and it is not advisable to implement another version. A document can use the standard hyperlink object to represent hyperlinks within itself, thus encapsulating the work of navigating, saving, loading, dragging, dropping, cutting, and pasting hyperlinks. Standard hyperlink objects are created through the HlinkCreateFromData, HlinkCreateFromMoniker, HlinkCreateFromString, and OleLoadFromStream functions. The standard hyperlink object implements the IHlink, IPersistStream, and IDataObject interfaces.

IHlink::GetHlinkSite Method

The hyperlink container
A hyperlink container is a document or application that contains hyperlinks. The container supports hyperlinks by implementing the IHlinkSite interface and, if the container's objects can be targets of other hyperlinks, the IHlinkTarget interface.

Note Generally, an object that acts as a hyperlink container can also act as a hyperlink target. An HTML page, for example, can contain a number of hyperlinks to other pages, while at the same time it can be the target of hyperlinks from other HTML pages.
The hyperlink site
A hyperlink site is a COM object that implements the IHlinkSite interface and supplies either the moniker or interface identifier of its hyperlink container. One hyperlink site can serve multiple hyperlinks. The moniker supplied by the hyperlink site is used to evaluate relative monikers to the hyperlink target. If the relative moniker is NULL, the target of the link is in the same container object, and IHlink::Navigate can result in an efficient internal jump

Note The standard hyperlink object performs internal jumps by retrieving the container's IHlinkTarget moniker using IHlinkTarget::GetMoniker (which avoids an unnecessary moniker bind). The object then asks the container to navigate directly through the IHlinkTarget::Navigate method
  • 打赏
  • 举报
回复
popyyb 2003-12-12
up
  • 打赏
  • 举报
回复
warton 2003-12-12
to tjandy把代码贴上来看一下吧!
  • 打赏
  • 举报
回复
liwz123 2003-12-12
to tjandy(ANDY) :
能否法我一份,谢谢了
lwz_li888@sohu.com
  • 打赏
  • 举报
回复
myb123 2003-12-12
谢谢tjandy(ANDY)了,
我的e-mail是mincpu@163.net
  • 打赏
  • 举报
回复
tjandy 2003-12-12
我有代码,你把邮箱给我,我发给你
  • 打赏
  • 举报
回复
liwz123 2003-12-12
up
  • 打赏
  • 举报
回复
相关推荐
我已经创建了一个ie扩充菜单 (1)在注册表HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt下新建一项,并且编辑右键功能如下: geturl.htm: