Recent

Author Topic: Get last "website visited" for app  (Read 2384 times)

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 594
    • Double Dummy Solver - free download
Get last "website visited" for app
« on: March 29, 2015, 08:16:40 pm »
  OpenURL() works great for letting the user go to the web with his default browser. When he closes the browser and returns to my app, I want the app to know the URL of the last page visited. Is there any way to capture that? Of course the browser keeps it's history -deep in its bowels - but I can't figure out how to get at that. Is there some way?
« Last Edit: March 29, 2015, 08:18:52 pm by bobonwhidbey »
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Get last "website visited" for app
« Reply #1 on: March 29, 2015, 08:26:04 pm »
Your app "knows" which URLs were visited since it passed it with OpenURL to the browser. The most straightforward solution is therefore that your app keeps track of them on its own, e.g. by storing them in a StringList and, for persistence, by saving this StringList as a tab-delimited file (or in another suitable format like CSV or XML). At OnShow or OnCreate it could check the StringList and, e.g., colourise the URLs in a different way (or do whatever action you desire).

The alternative way would be to communicate with your browser and get the history list. This option is, however, browser- and platform-dependent.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 594
    • Double Dummy Solver - free download
Re: Get last "website visited" for app
« Reply #2 on: March 29, 2015, 08:48:51 pm »
In my app, the user will always go to several other pages after the initial page opened with OpenURL. What I want to capture it the last page visited.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Get last "website visited" for app
« Reply #3 on: March 29, 2015, 08:55:43 pm »
In my app, the user will always go to several other pages after the initial page opened with OpenURL. What I want to capture it the last page visited.
Not with plain OpenURL since it only asks the OS which default app is registered to open a URL, or searches its own list of well known browser executables. The control goes to the respective app since then. The only viable solution I can imagine is to use embedded browser (so that you have full control of it including its events) and communicate with it accordingly.

 

TinyPortal © 2005-2018