[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Inserting text into a KHTMLPart?
From:       David Faure <faure () kde ! org>
Date:       2005-03-27 14:46:38
Message-ID: 200503271646.39121.faure () kde ! org
[Download RAW message or body]

On Sunday 27 March 2005 09:46, Ace Jones wrote:
> Hi, all.  Could anyone tell me how to insert some text into a KHTMLPart
> at a certain place controlled by the markup in the part?
> 
> So I have a file, call it "welcome.html" that's written by an HTML
> writer.  There are certain places where links have to be inserted
> conditionally depending on the state of the program.  So I'd like to be
> able to give him some markup to insert that would serve as a flag for the
> program to replace with the right conditional markup.
> 
> e.g. He inserts '<a id="blah"></a>', and then at runtime I replace
> that with a link or whatever else I'd want.

One solution is to use %1 in the HTML and QString::arg in the code - see \
kdebase/konqueror/about.

The other, more dynamic, solution, is to use the DOM (via C++ or via javascript) to \
set the contents of the element, e.g. \
htmlpart->evaluate("document.getElementById('blah').href='http://www.kde.org'). But \
if all you need is to set the link once, when loading the HTML file, then this is \
probably overkill and a simple search-n-replace is enough.

-- 
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
 
> > Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic