WebBrowser - OnClick event for " Web Page - History back.go(-1)" Problem

Posted on 2004-10-28
Last Modified: 2008-01-09
Hello All;

  Below is information that I have tried, but has not worked.
( Mention, everything works like it suppose to in "IE" but when used
In code like what I am doing here, it does not work, )

  I have done this to the link.

<A HREF="JavaScript: history.go(-1)" id="history">

I have done this in code

I receive an "HTML Page Error" Method not supported.
Within the page itself, not Delphi Error.

So I went in and changed the code in the page ( It is a CGI page, so I had to do some research on how to implement it.
And it is just like regular HTML for <form>'s and <input Type> of parameters )

<INPUT type="Submit" NAME="SpiderHistory" value="Click here to go back" onClick="history.back(-1)" STYLE="color: #000080; border-style: ridge" >

The above code, works extremely well, and gives the " History - Back " Button a new look, A lot better feel.
And when using it in " IE " it works like it suppose too. ( The page pulls information from a MySQL Database, This goes to the Last Record in the MySQL Database, that I was at )

BUT?? When used in the "WebBrowser" Project,( If I click on the link myself, with "MouseClick" then it works like it suppose too ) but with it placed on the "OnDocumentComplete" it is not going back properly. Instead it is going " All the way " Back to the beginning of the page.
Instead of where I "Last Was" ( so it suppose to go back to the last record, instead It is going back to the <top> of the Table )

This is the code that I am using to implement the "OnClick" Behavior in Delphi's WebBrowser (EmbeddedWB)

procedure TCFF_Spider.AdminWebDocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
  SpiderSubmit : IHTMLInputElement;
  MyDocument : IHTMLDocument3;
   MyDocument := AdminWeb.Document as IHTMLDocument3;
   if assigned(MyDocument) then
   SpiderSubmit := (MyDocument.getElementsByName('SpiderHistory').item(0,'')as IHTMLInputElement);
   if assigned(SpiderSubmit) then

end; end;

Any idea's. on Why? This is not working correctly, please help

Thank You
Question by:Wayne Barron
    LVL 26

    Expert Comment

    Have you used the click method of the submit button instead of submit?
    LVL 30

    Author Comment

    by:Wayne Barron
    Hello Again Eddie;

      It is not giving me the Option of: SpiderSubmit.Click; ?
    Undeclaired Identifier.

    LVL 26

    Expert Comment

    Can you give me a URL or HTML source so I can mock it up here?
    LVL 30

    Author Comment

    by:Wayne Barron
    Cannot give the URL it is in the "Admin" of a Business site.
    The code is CGI/Perl HTML so cannot do much to it.

    Here is the actual line.

    Original Code
    print qq!<P ALIGN="center"><A HREF="javascript: history.go(-1)()"><B><FONT COLOR="BLUE">Back To Previous Window</FONT></B></A></P>!;      

    Updated Code to use <FORM> Method
    print qq!<P ALIGN="center"><FORM> <INPUT type="submit" NAME="SpiderHistory" onClick="JavaScript:history.go(-1)" value="Click here to go back" STYLE="color: #000080; border-style: ridge"> </FORM> </P>!;      

    The Original code is when clicked on with "Mouse" in the WebBrowser Project, works as designed.
    But when clicked on it designTime, it takes it back to the beginning
    Of the "MySQL" Database Categories.
    Instead of going back to the "Previous Database Category" that
    I was at previously.
    ( Hope that makes since to you )

    If there is anything else that you may need please let me know.
    And I will try to get it for you.

    This is a "Internet Search Engine" site. As you can tell by the: Spider
    I have made a program that will make it faster to grab links and submit them into the "Spider" of the Search Engine and then [Submit] the Spider to extract the Sites data.

    And this problem, is trying to get back to the last page, so that I do not have to start over everytime. (or) hit the Back-Space button.
    In the program.

    There are MILLIONS upon Millions of sites out there, that I need to get into the Search Engine, and once this program is completed, It should make everything 10x faster...  I am hoping anyway.
    As with the program's Site Link Stripper.
    I can do about 1000 links in a 5 hour period.
    I am hoping that I can double that with this program. If not,
    Then it is a waste, having this feature to Submit in it.
    Then I will go back to 1000 links manually again.

    Sorry for the Book here, just wanted to let you know what the project is for, and why I am so eager to get this Click to work on the "Javascript" History link.

    Take Care
    LVL 26

    Accepted Solution

    Wayne, Have you tried using the GoBack method in TWebBrowser?
    LVL 30

    Author Comment

    by:Wayne Barron
    OK< You made me think ???
      So I went in and changed "1" single line of code:



    Wa-La...... Works like a complete "EddieShipman" Charm :-)

    Thank you for reminding me of something that I have done so many times before. But forgot.

    Thank You Once Again

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    The Complete Ruby on Rails Developer Course

    Ruby on Rails is one of the most popular web development frameworks, and a useful tool used by both startups and more established companies to build strong graphic user interfaces, and responsive websites and apps.

    Suggested Solutions

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    845 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    3 Experts available now in Live!

    Get 1:1 Help Now