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

List:       konq-e
Subject:    Re: How to write a new object for javascript
From:       "Paul Chitescu" <Paul.Chitescu () IMC-Group ! org>
Date:       2004-02-19 11:37:15
Message-ID: 004601c3f6dc$bac952e0$e7b9e6c1 () s40 ! icpe ! ro
[Download RAW message or body]

Look in add-ons/jsdebug/jsdebug.cpp for an example on how to add a function
to all or just some pages.

You may want to insert an object derived from ConstructorImp so that you can
create objects using the "var name = new
SomeObjectName(construct_parameters);" syntax.

You can also selectively add that object only to pages in a specific domain
of URLs or MIME types as these are passed to the extension function. You may
want to do it like this, to select only local HTML pages:

if (part->inherits("KHTMLPart") &&
KIO::File::implementsProto(url.protocol()))
{
    ... insert objects or whatever
}

You may insert the new function or object directly into the hostobj (which
for KHTML is the global object) or in externalObject() which will make your
object belong to an "external" object:

var myvar = new external.SpecialObject;

The API is defined in dropin/jsextension.h and is Konq/E specific. At
program init time you must call addJsExtension to insert your callback
function in the global list held by the engine. Every time a new
js-knowdlegeable part is created (currently only KHTMLPart) the callback is
called giving it a chance to make changes.

--
 Paul Chitescu
 pchitescu@null.ro   http://pchitescu.null.ro/   ICQ:22641673
 Any spammers will be painfully squeezed into /dev/null


_______________________________________________
konq-e mailing list
konq-e@kde.org
https://mail.kde.org/mailman/listinfo/konq-e
[prev in list] [next in list] [prev in thread] [next in thread] 

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