Delphi WebBrowser need true source

Posted on 2012-08-20
Medium Priority
Last Modified: 2012-11-04
Delphi WebBrowser view is  eat spaces.
I use the webbrowser element all the time.
But I am doing an app and there is a consern it is
removing spaces (not Carrage Returns) from the text.

It is a very standard call,
I tested all Inner, outer, text and html
all return the same line of text , with only single spaces,
between works,  the provider says the string should have
spaces to I can wrap at 76 Chars.  
The Line I get back has 'no' Carrage returns in it , by design

HOW DO I KNOW IT IS EATING SPACES, not returning them to me.
if I I right click the window and view source you see the spaces in Notepad.
But the iall.outerHTML; innerHTML ect does not return
what I see in Notepad when I view source

HELP  How do I fix this. ??

procedure TForm1.GetCompleteHTMLSource(wb: TWebBrowser);
  iDoc: IHTMLDocument2;
  iall : IHTMLElement;
  if Assigned(wb.Document) then begin

    iDoc := wb.Document as IHTMLDocument2;
    iall := iDoc.body;

    while iall.parentElement <> nil do begin
      iall := iall.parentElement;

    Memo1.Text := iall.outerHTML;

Question by:yahoolane
  • 2
LVL 38

Expert Comment

by:Geert Gruwez
ID: 38315099
if the webbrowser being used follows the W3C standards (w3c.org) then you can use the "no breaking space" &nbsp; instead of a space to align data

if you want to align characters you should use a single width character type (like Courier new)

however all this *behaviour* can be overridden by a style sheet

there is no sure way for you to control the visual output at the other end
LVL 38

Expert Comment

by:Geert Gruwez
ID: 38315106
next to that... the web pages can be created dynamically by sources you can't access
you can even write a delphi program which throws you random pages with random content

what are you trying to accomplish ?
LVL 28

Accepted Solution

Sinisa Vuk earned 2000 total points
ID: 38315881
Take a note - outerHTML is what you see and innerHTML is html source of that. If you assign
outerHTML to memo you surely lost something. Try to save raw data to file and look with hex view editor. If you want all of html source, try to iterate all frames first or look
something like this:


Author Closing Comment

ID: 38565596

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question