怎样读取webbrowser中正在显示的页面URL?
HELP!

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
    doc:IHTMLDocument2;
    begin
    doc := WebBrowser1.Document as IHTMLDocument2;
    memo1.text:=doc.body.innerHTML ;
    NavigateFrameset(doc) ;
    end;procedure TForm1.NavigateFrameset(document: IHTMLDocument2);
    var
        index: Integer;
        ole_index: OleVariant;
        frame_dispatch: IDispatch;
        framed: IHTMLWindow2;
    begin
        if document = nil then
            exit;
        try
            Application.MessageBox(
                PChar('Content:' + String(document.body.innerHTML)),
                PChar('URL: ' + String(document.URL)),MB_OK or
                MB_ICONINFORMATION);
            for index := 1 to document.Frames.Length do
            try
                ole_index := index-1;
                frame_dispatch := document.Frames.Item(ole_index);
                if frame_dispatch <> nil then
                begin
                    framed := frame_dispatch as IHTMLWindow2;
                    NavigateFrameset(framed.document);
                end;
            except
                on E: Exception do
                begin
                end
            end;
        except
            on E: Exception do
                begin
                    Application.MessageBox(PChar(E.Message),
                    PChar('Exception'));
                end;
        end;
    end;
    import the "Microsoft HTML Object Library" (MSHTML.TLB) and include MSHTML_TLB in the unit's uses clause
    这个问题困扰我很长时间,今天彻底解决了,希望和大家共享,绝对通过了,别怕麻烦,你拷贝过去,试验一下
    可以显示所有frame