cristianotestai Posted July 29, 2016 Posted July 29, 2016 Hi, I have a simple function below that returns a href string. How do i run the link returned by the function? I try with AddJS, but without sucess. function GeHref: string; begin Result: = '<a href="mailto:name@host.com"> </a>'; end; procedure UniButtom1Click(Sender: TObject); var link: string; begin link: = GeHref; //How do i execute the string returned by the function? end; Thanks. Quote
Sherzod Posted July 30, 2016 Posted July 30, 2016 Hi Cristiano, Well, if I understand correctly you, you always have a string with the tag <a> Then try the following: procedure UniButtom1Click(Sender: TObject); var link: string; begin link: = GeHref; //How do i execute the string returned by the function? link := link.Replace(' ', ''); link := link.Substring(Pos('href="', link)+5); link := Copy(link, 1, Pos('"', link)-1); // Or you can use regular expressions UniSession.BrowserWindow(link, 0, 0, '_blank'); end; Best regards. Quote
cristianotestai Posted July 30, 2016 Author Posted July 30, 2016 Hi Delphi Developer!Thanks for your answer! It worked almost 100%.In my case I always return the string with the syntax "mailto:" to open the user's email program. With this, I have three issues to resolve:1) How do I indicate that it should open a new folder and not a new window?2) In Chrome, the URL open in new window is showing all the contents of the string mailto, which should show _blank only. In Firefox it is ok. Any idea?3) The third issue I think is the most difficult. I wanted to identify if the user uses a standard desktop email program such as Windows Live, Thunderbird, or any other. If use, just run the "mailto" URL without opening new folder or new window, in which case it will open the default e-mail program, no need to create new window.Thanks for your help! Best Regards, Cristiano Quote
zilav Posted July 31, 2016 Posted July 31, 2016 The only way is to actually force user to click the link, this is a security measure in browsers to prevent sites from launching associated apps themselves. the same way as browsers asking you what to do with downloaded file instead of launching associated apps on their own. If your mailto address depends on lets say the selected row in dbgrid, update UniLabel link in AfterScroll event. Quote
cristianotestai Posted August 2, 2016 Author Posted August 2, 2016 Hi zilav, In my app, the user query and selects in the grid which customers want to send email. With selected records, he click on a button that internal search all selected records and create the string with the syntax "mailto" with all emails. In this case, it must be executed on return of this function, without user intervention, as are several emails indicated in the mailto syntax. Thanks for help. Quote
zilav Posted August 3, 2016 Posted August 3, 2016 Then you need to update the link in "onselect", "oncheck" or whatever event is called upon records selection by calling ajaxRequest. Ping Delphi Developer, he is our pro at ExtJS events Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.