Hi,
What you can also do is to write your own protocol handler.
say tom://localhost/myfile.html. Then call nsIWebNavigation::LoadURI
with URE set as above.
In the protocol handler's GetData method you provide your
html string as a nsIByteArraryInputStream and feed it into
the embeded browser.
Steve
Aleksandar Vasilev writes:
Hello Tom,
Didn't understand quite well what you mean by "the content that is
rendered contains a link to a web page is there any way that i could
intercept this request", but i suppose you want to intercept navigation
events, like the user clicking on a link, or javascript opening a link.
Yes, there is a way. You have to create an instance supporting
nsIURIContentListener, register it and you will get navigation requests in
the OnStartURIOpen method. You allow or cancel navigation by returning
true or false through the *_retval parameter. You can inspect the link
that was going to be loaded, and "tell" the browser to load another link
in teh way you usually do. However, here is a hint: since you are in a
callback, any metod that you call from this callback that enters mozilla
again, causes reentrancy. From what I have seen, Mozilla guards itself
from this, but you can have unexpected results. For example, trying to
load a page from the callback works, but if you want to wait for the page
being completely loaded, you may end up in a deadlock. It seems(at least
on windows, but re-entrancy is a generic problem), that Mozilla does the
actual loading on the next iteration of the message loop. And of you do
the wait before this, you will never get the page loaded, even if you
re-enter the message loop explicitly. This is why it is a good idea in
this case to initiate (and wait if necessary) page loading, by a
message/event handler that handles an event, posted from the callback. For
intercepting navigation events, and for other stuff you can look at
http://www.mozilla.org/projects/embedding/faq.html. Hope that helps.
Regards
Alex
Tom Gethings wrote:
Thanks for your help! At the moment i am attempting this using the
Write() operation for the nsIHTMLDocument. I have another question
though, if the content that is rendered contains a link to a web page is
there any way that i could intercept this request and instead supply a
local file instead?
On 01/02/06, *Aleksandar Vasilev* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hello Tom,
One way to do this is to use the method setInnerHTML of the interface
nsIDOMNSHTMLElement to set the inner html of the body element, or any
element you want (you can use getElementById to find the appropriate
element). These techiques are often used in javascript/AJAX. To
use this
method you will have to escape any '<' and '>' symbols with their html
representations. There is another solution -
nsIHTMLEditor::InsertHTML,
but you can do this only if you set mozilla to editing mode. Hope this
helps.
Regards
Alex
Tom Gethings wrote:
> I am trying to create a very simple application which embeds gecko,
> something like winEmbed. One of the main features i would like to
> implement is the ability to pass a string of HTML for my application
> to render. I was wondering if there is any method available to
> perform something like this? I have found something similar to
what i
> would like in the gtkmozembed program, gtk_moz_embed_render_data, is
> there a version of this method for a windows example?
>
> Thanks in advance for any help,
> Tom
>
>------------------------------------------------------------------------
>
>_______________________________________________
>dev-embedding mailing list
>[email protected]
<mailto:[email protected]>
>https://lists.mozilla.org/listinfo/dev-embedding
>
>
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding