Jump to content

Switch between url and html of URLFRAME


allenchow

Recommended Posts

When I try to switch with 2 buttons :

 

1 set URL to UniURLFRAME1 and 1 set HTML content into it

But I can only load URL , but cannot show HTML content , unless I show HTML content first . But after switch to URL again, I cannot show HTML again .

Please help !

Link to comment
Share on other sites

Hi,

 

I think you need to change the logic.

 

After set the "URL" you must "clear" URL (UniURLFrame1.URL := '';) if you want to use UniURLFrame1.HTML.Text, and handle it in OnFrameLoaded event,

 

Can you try it?!

 

Best regards,

Link to comment
Share on other sites

Hi,

 

Actually I have used UniURLFrame1.URL := ''; but the result is the same.

What should I do inside OnFrameLoaded ?

 

Also there's an error as attachment when I click HTML after clicking URL

 

Well, for example like this:

  public
    { Public declarations }
    isHTML: Boolean;
    HTMLstr: string;
  end;
procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  isHTML := True;
  HTMLstr := '<html><body>Test ! </body></html>';
  UniURLFrame1.URL := '';
  //UniURLFrame1.HTML.Text := '<html><body>Test ! </body></html>';
end;

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
  isHTML := False;
  UniURLFrame1.URL := 'http://www.xyz.com';
end;

procedure TMainForm.UniURLFrame1FrameLoaded(Sender: TObject);
begin
  if (isHTML) and (HTMLstr<>'') then
  begin
    isHTML := False;
    UniURLFrame1.HTML.Text := HTMLstr;
  end;
end;

Best regards,

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...