![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 10 of 13 total |
![]() |
Wed, Sep 30 2015 8:24 AM | Permanent Link |
PA | What I need to achieve:
1. Get the HTML served by a PHP script from the Internet 2. Extract the whole tag <div id="content"> from this HTML 3. Replace the whole <div id="content"> tag from a Browser2 HTML document with the above whole <div id="content"> tag. Is this possible? |
Wed, Sep 30 2015 8:53 AM | Permanent Link |
Matthew Jones | PA wrote:
> What I need to achieve: > > 1. Get the HTML served by a PHP script from the Internet > > 2. Extract the whole tag <div id="content"> from this HTML > > 3. Replace the whole <div id="content"> tag from a Browser2 HTML > document with the above whole <div id="content"> tag. > > Is this possible? The DocumentText property should allow you access. -- Matthew Jones |
Wed, Sep 30 2015 8:54 AM | Permanent Link |
Matthew Jones | Matthew Jones wrote:
> The DocumentText property should allow you access. That said, I wonder if the browser will allow it to be read - that might be a security issue. I know you can write it. -- Matthew Jones |
Wed, Sep 30 2015 9:28 AM | Permanent Link |
PA | This code:
procedure TForm1.Button1Click(Sender: TObject); begin MultiLineEdit1.Lines.Text := Browser1.DocumentText; end; gives me this error in all browsers: http://i.imgur.com/ozg4QvL.png |
Wed, Sep 30 2015 9:31 AM | Permanent Link |
PA | So how can I get the HTML output from an Internet PHP URL? Is there a built-in function for this in EWB?
|
Wed, Sep 30 2015 9:36 AM | Permanent Link |
Raul Globestar Systems ![]() | On 9/30/2015 9:31 AM, PA wrote:
> So how can I get the HTML output from an Internet PHP URL? Is there a built-in function for this in EWB? Yes - you need to issue a TServerRequest (http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Executing_Request) to get access to the raw response from URL. The only downside of this approach is that now you're not a browser and any javascript does not get executed (if there are scripts on the page that change page content client side then those you will not see). Raul |
Wed, Sep 30 2015 10:00 AM | Permanent Link |
Raul Globestar Systems ![]() | On 9/30/2015 8:24 AM, PA wrote:
> What I need to achieve: > 1. Get the HTML served by a PHP script from the Internet > 2. Extract the whole tag <div id="content"> from this HTML > 3. Replace the whole <div id="content"> tag from a Browser2 HTML document with the above whole <div id="content"> tag. > Is this possible? Not in a straight forward way. What you're asking is equivalent to : Loading some secure site (web banking, etc) and replacing parts of it (for example authentication url to point to your ) and then showing modified page to user and have them fill it in and submit. This is one of the reason browsers disallow DOM modification from outside. What you could do is : 1. use TBrowser to load the page 1 and extract the div you need 2. user TServererquest to download content for page 2 3. replace the div's as needed on page 2 4. locally load the final html you have in a local variable into tbrowser (note that you're now loading it locally from html so it would likely break any relative paths to images, scripts etc). Raul |
Wed, Sep 30 2015 12:56 PM | Permanent Link |
PA | Raul wrote:
> What you could do is : > 1. use TBrowser to load the page 1 and extract the div you need This creates an error, as I wrote above: procedure TForm1.Button1Click(Sender: TObject); begin MultiLineEdit1.Lines.Text := Browser1.DocumentText; end; gives me this error in all browsers: http://i.imgur.com/ozg4QvL.png |
Wed, Sep 30 2015 1:12 PM | Permanent Link |
Raul Globestar Systems ![]() | On 9/30/2015 12:56 PM, PA wrote:
> MultiLineEdit1.Lines.Text := Browser1.DocumentText; > gives me this error in all browsers: I'm getting a more useful error in Chrome which is "Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://localhost" from accessing a cross-origin frame." So looks like security is actually tighter than i though - you can only do same domain document content reads. So if you're hosting the EWB app from the exact same domain (meaning host + port) then you can access the DocumentText (i just tested and it works fine). However if domain is different then you need to use TServerRequest for page 1 as well so sequence is : 1. use TServerRequest to retrieve page 1 2. extract any div section(s) you need 2. use TServerRequest to retrieve page 2 3. replace any sections in page 2 with sections from page 1 4. load the final page 2 document into tbrowser (same considerations as before) Raul |
Wed, Sep 30 2015 1:53 PM | Permanent Link |
PA | Raul wrote:
> 1. use TServerRequest to retrieve page 1 This page says that TServerRequest can also only be used to access resources from the same origin: "Most modern web browsers will prevent server requests that don't access resources that are from the same origin": http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Executing_Request |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Thursday, March 23, 2023 at 02:07 AM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |