Subject Filed
asked 8 years ago

When I try posting an answer by copying and pasting something with html formating from a browser the view results shows html code only.  Example posting the following as an answer in the DW Answer section of my website.
The trick is give the focus to the WebBrowser component:

<span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #00008b; background: transparent;">procedure</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;"> TFormBrowserAdd</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">ButtonNavigateClick</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">Sender</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">:</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;"> TObject</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">);</span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #00008b; background: transparent;">begin</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">
  WebBrowser</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">CanFocus </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">:=</span><span class="lit" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #800000; background: transparent;">True</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">;</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">
  WebBrowser</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">Navigate</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">(</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">EditUrl</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">Text</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">);</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">
  WebBrowser</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">.</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">SetFocus</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">;</span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #00008b; background: transparent;">end</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; color: #000000; background: transparent;">;</span>

But, after that the back key will not work correctly so you have to manage in other way. For example i have used a button on my form.

Subject Filed
replied 8 years ago

The above html code when shown correctly should have read:

The trick is give the focus to the WebBrowser component:
procedure TFormBrowserAdd.ButtonNavigateClick(Sender: TObject);
begin
WebBrowser.CanFocus := True;
WebBrowser.Navigate(EditUrl.Text);
WebBrowser.SetFocus;
end;
But, after that the back key will not work correctly so you have to manage in other way. For example i have used a button on my form.

2 Answers
BigHug
answered 8 years ago

Hi there,
Please try to use this combination when you paste your content: Ctrl + Shift + V
This way you will eliminate the html part. Please try and let us know if it works.

Subject Filed
replied 8 years ago

Thanks so much for your response. I will give this a try now in the “Answer this question” section below. This will definitely work because at that point its text only. My issue is really with educating users that do copy and paste with html formatting. When you first paste the content, it looks correct. Its only after you click on “Add answer” the formatting gets weird.

Subject Filed
answered 8 years ago

Test using “Ctrl + Shift + V” as suggested above.

The trick is give the focus to the WebBrowser component:
procedure TFormBrowserAdd.ButtonNavigateClick(Sender: TObject);
begin
  WebBrowser.CanFocus := True;
  WebBrowser.Navigate(EditUrl.Text);
  WebBrowser.SetFocus;
end;
But, after that the back key will not work correctly so you have to manage in other way. For example i have used a button on my form.

BigHug
replied 8 years ago

So the combination works for you now?

Powered by DW Question & Answer Pro