KDE TechBase
  • Page
  • Discussion
  • Edit
  • History
KDE TechBase is a Wiki - You can help! Please contribute! Questions?
Please ask development related questions in the KDE Community Forum.

Development/Architecture/KDE3/KHTML

< Development | Architecture | KDE3

Contents

  • 1 KHTML - KDE's HTML library
  • 2 Small example
  • 3 Document Object Model (DOM)
  • 4 Java
  • 5 JavaScript (ECMA-Script)
  • 6 Cascading Style Sheets (CSS)

[edit] KHTML - KDE's HTML library

KHTML is an XML/HTML4 compliant HTML library, with support for DOM, Java, JavaScript and Cascading Style Sheets (CSS).

You can get an overview of KHTML's current capabilities here.

[edit] Small example

Using KHTML in your program is quite easy. The following example shows you a complete application with which you can already browse the web:


Invalid language argument, "cppqt3", select one from the list:
actionscript3
ocaml-brief
dcs
cfdg
gnuplot
whitespace
lisp
cpp
xml
ocaml
prolog
reg
diff
css
providex
pixelbender
xpp
applescript
thinbasic
c
d
caddcl
freebasic
lolcode
actionscript
cpp-qt
dos
dot
sas
cmake
winbatch
hq9plus
abap
cadlisp
oobas
delphi
rebol
haskell
ruby
povray
progress
kixtart
purebasic
oberon2
email
groovy
oracle11
pascal
c_mac
lsl2
vbnet
tcl
tsql
make
cppqt
apache
matlab
sql
php-brief
klonec
lua
text
scala
m68k
bf
html4strict
autoit
scilab
autohotkey
sdlbasic
fo
oracle8
glsl
smarty
lscript
robots
io
xorg_conf
typoscript
python
visualfoxpro
nsis
z80
ada
gml
cobol
smalltalk
bibtex
csharp
apt_sources
mirc
po
gdb_backtrace
eiffel
modula3
vb
basic4gl
objc
whois
lotusformulas
genero
java
qbasic
vim
verilog
gettext
mxml
pic16
idl
klonecpp
vhdl
plsql
asm
asp
per
visualprolog
javascript
rails
php
awk
mysql
latex
powershell
locobasic
blitzbasic
erlang
bnf
java5
teraterm
intercal
mpasm
ini
boo
bash
inno
cfm
fortran
rsplus
perl
cil
scheme
lotusscript
avisynth
properties

This small example already gives you a functional browser, that lets you browse the web (you'll need the kio_http executable from KDE though to access non local files). Just try testkhtml http://www.kde.org and you will get a widget showing KDE's home page.

KHTML has a lot of functionality. Almost everything you'll ever need can be accessed through the member functions of the class KHTMLWidget.

[edit] Document Object Model (DOM)

KHTML provides a mostly complete implementation of Dom Level 1 and 2.

The DOM is an implementation using internal classes to hold the document's data. The classes accessing the DOM are using a refcounting scheme to hold the data. Thus the DOM does the memory management for you. You can just use the classes defined in the DOM header files to access parts of the document. As long as you don't use pointers, you will not get memory leaks.

You can easily access the document being shown by the KHTMLWidget::document() method, from where you can get access to every part of the document.

[edit] Java

Thanks to the work of Richard Moore, KHTML can display Java applets. Java is not enabled by default, but you can do so by using KHTMLWidget::setEnableJava(true);, and setting the environment variable CLASSPATH to:

CLASSPATH=$KDEDIR/share/apps/kjava/kjava-classes.zip:$JDK_DIR/lib

You will need to have the java developers kit installed though. I tested it with JDK-1.1.7, and don't know if it'll run with other versions of JDK or with Kaffe.

[edit] JavaScript (ECMA-Script)

The JavaScript support aims at compliance with the ECMAScript Language specification ECMA-262 3rd edition. This roughly equals JavaScript 1.5.

[edit] Cascading Style Sheets (CSS)

Cascading style sheets 2.1 are mostly supported now.


Initial Author: Lars Knoll

Retrieved from "http://techbase.kde.org/Development/Architecture/KDE3/KHTML"
Categories: KDE3 | Architecture

Navigation

  • Home
  • Help
  • Recent changes

Sections

  • Getting started
  • Development
  • Schedules
  • Policies
  • Contribute
  • Projects

Toolbox

  • What links here
  • Related changes
  • Special pages
  • Printable version
  • Permanent link

Personal tools

  • 38.107.191.98
  • Talk for this IP
  • Log in / create account
  • Login with OpenID
Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal