Jump to content


Photo

uniurlframe get html


  • Please log in to reply
9 replies to this topic

#1 Didier

Didier

    Newbie

  • uniGUI Subscriber
  • Pip
  • 8 posts
  • LocationFRANCE

Posted 15 May 2018 - 10:23 AM

hello,

 

I have a TUniURLFrame (wbSearchAnnonce).

I just do : wbSearchAnnonce.url := mypage

 

but i don't know how to get the html code.

 

i ve done :

procedure TFrameDossier.wbSearchAnnonceFrameLoaded(Sender: TObject);
begin
  UniSession.AddJS('ajaxRequest('+wbSearchAnnonce.JSName + ',"gethtml" , ["_value="+document.getElementsByName("html").innerHTML])');
end;

 

procedure TFrameDossier.wbSearchAnnonceAjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  FSourceHtml := '123';

  if EventName='gethtml' then
  begin
    FSourceHtml :=Params.Values['_value'];
    if FSourceHtml<>'' then
      UniSession.AddJS('alert("Custom JS Code") ' + FSourceHtml)
    else
      UniSession.AddJS('alert("Vide")')
  end;
end;

 

But FSourceHtml is allways at 'undefined'

 

 

Can you help me please ?


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4754 posts

Posted 15 May 2018 - 10:43 AM

Hi,

 

I have a TUniURLFrame (wbSearchAnnonce).

I just do : wbSearchAnnonce.url := mypage

 

mypage - what is this URL?


  • 0

#3 Didier

Didier

    Newbie

  • uniGUI Subscriber
  • Pip
  • 8 posts
  • LocationFRANCE

Posted 15 May 2018 - 11:56 AM

just one url like https://www.google.fr/


  • 0

#4 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4754 posts

Posted 15 May 2018 - 12:46 PM

just one url like https://www.google.fr/

 

Well, this URL will not open at all


  • 0

#5 Didier

Didier

    Newbie

  • uniGUI Subscriber
  • Pip
  • 8 posts
  • LocationFRANCE

Posted 15 May 2018 - 01:16 PM

It's not the problem of the url.

You can go at any you want.

if '.fr' don't work for you, try for exemple 'https://www.google.com'

 

But in my application, customers can navigate, so url will change.

when he click on a button, i must parse the html to find some words a search.

So my problem is how to have the html text.


  • 0

#6 delagoutte

delagoutte

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 331 posts

Posted 17 May 2018 - 02:02 PM

i think Didier would like to have a method for sending the html source code of a page that is loaded in a UniUrlFrame to the App unigui.

 

for example, open the sample of unigui desktop "URLFrame" , launch the app,  navigate to an adress in the app -> how to recover the html source code that is contained in the uniUrlFrame1 ? and how send it to the main app ?


  • 0

#7 Oliver Morsch

Oliver Morsch

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 267 posts
  • LocationGermany

Posted 17 May 2018 - 05:05 PM

i think Didier would like to have a method for sending the html source code of a page that is loaded in a UniUrlFrame to the App unigui.

 

for example, open the sample of unigui desktop "URLFrame" , launch the app,  navigate to an adress in the app -> how to recover the html source code that is contained in the uniUrlFrame1 ? and how send it to the main app ?

 

UniUrlFrame uses an iFrame. And the browser prevents accessing an iframe, when it conflicts with the "same origin policy". This is for security in web (XSS, ...). So you can't get the html code.


  • 0

#8 delagoutte

delagoutte

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 331 posts

Posted 18 May 2018 - 07:03 AM

And if we control the both webserver that are on two domain (one for unigui app and the other for the page in iframe), is it possible ? could we configure server or app for having this possibility ?

i try adding Access-Control-Allow-Origin: * in the header but without success. but maybe i don't do it with the good method.


  • 0

#9 Oliver Morsch

Oliver Morsch

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 267 posts
  • LocationGermany

Posted 18 May 2018 - 10:44 AM

"Access-Control-Allow-Origin" is for XHR.

 

If you use subdomains you can use 

<script>document.domain = 'example.com'</script>

for sub1.example.com and sub2.example.com. See here.

 

And here are additional informations: https://benohead.com...n-with-iframes/


  • 0

#10 Didier

Didier

    Newbie

  • uniGUI Subscriber
  • Pip
  • 8 posts
  • LocationFRANCE

Posted Today, 08:08 AM

Thank you,

 

I'll try to do from this way.


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users