new JavaScript objects
Paul Chitescu
Paul.Chitescu at IMC-Group.org
Wed Jun 4 19:28:53 CEST 2003
> Hi Luciano,
> thanks for your help
> I have seen the example that you suggest but it is not clear enough the
way that the Konq-embed has to register the new javascript objects and where
the Konq evaluates the new objects.
>
> Ancora grazie,
> un saluto
> Caterina.
Sometimes during init the extension callback should be registered via
KJS::addJsExtension(&mycallback). There is no way to unregister an
extension - you have to shut down the browser.
Later, each time a new HTMLView is created all registered callback functions
are called with the following parameters:
- the KParts::ReadOnlyPart for which the interpreter is created (check this
if it inherits("KHTMLPart") ) - most extensions objects will want to store a
copy of this pointer internally
- the URL of this page (many extensions will want to perform some security
check or only install on local URLs - hint:
KIO::File::implementsProto(url.protocol()) )
- the MIME type - this is usually text/html but not always
- the KJS::KJSO object in which the objects should be inserted; normally
this is the global object of the window. For embedded objects (like the
simple sound sample) this is the EMBED object reflected from DOM - this is
currently broken by concept.
You should do anything you want with the JS object - normally you put()
something in it - a variable, a function, an object, a constructor. The
jsdebug sample adds just a single function but you can add any number of
them.
As soon as I check all the security implications I'll upload an extension
that adds client sockets (TCP and UNIX) capabilities. This one inserts a
(simplified) constructor and deals with some unexpected side effects of the
Javascript objects like their late (or missing!) destruction.
I have also an extension that allows a page to dynamically create KActions
and handle toolbar buttons from Javascript code.
Paul Chitescu
--
Paul Chitescu
pchitescu at null.ro http://pchitescu.null.ro/ ICQ:22641673
Any spammers will be painfully squeezed into /dev/null
More information about the konq-e
mailing list