• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1459
  • Last Modified:

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

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
Wayne Barron
Wayne Barron
  • 3
  • 3
1 Solution
Eddie ShipmanAll-around developerCommented:
Have you used the click method of the submit button instead of submit?
Wayne BarronAuthor Commented:
Hello Again Eddie;

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

Eddie ShipmanAll-around developerCommented:
Can you give me a URL or HTML source so I can mock it up here?
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Wayne BarronAuthor Commented:
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
Eddie ShipmanAll-around developerCommented:
Wayne, Have you tried using the GoBack method in TWebBrowser?
Wayne BarronAuthor Commented:
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now