On 26 nov, 15:47, Blaine Monkey <[email protected]> wrote:
> On 26 nov, 11:50, Blaine Monkey <[email protected]> wrote:
>
>
>
> > I've a Linux C++ application with mozilla browser embedded.
> > The embedded browser shows the google page well.
> > I made a simple page with some javascript code, to do a test. The page has a
> > table with a text and the javascript changes the text with an image. If I
> > open the page with firefox it shows fine, but the embedded browser only
> > shows the text. Embedded browser supports javascript as firefox, in't it?
> > What's the problem?
>
> > Here is the source code:
>
> > <html>
> >  <head><title>TESTING</title>
> >     <script src="buildTable.js" type="text/javascript"></script>
> >  </head>
> >     <body bgColor="yellow" onload="buildTable();">
> >       <table id="myTable" border="2" width="400" height="400"><tr><td><span>
> > TEXT </span></td</tr><table/>
>
> >     </body>
> > </html>
>
> > // And this is the code of buildTable.js file:
> > function buildTable(){
> >  var build = '<tr><td><img src="food020.jpg" width="100"
> > height="100"></img></td></tr>';
> >     document.all.myTable.innerHTML=build;
>
> > }
>
> This is the application code:
>
> int main(int argc, char** argv) {
>         GtkWidget *window;
>         nsCOMPtr<nsIBaseWindow> baseWindow;
>         nsCOMPtr<nsIWebBrowser> webBrowser;
>         nsCOMPtr<nsILocalFile> libxul;
>         nsCOMPtr<nsIWebNavigation> webNavigation;
>         nsCOMPtr<nsIWebBrowserSetup> browserSetup;
>         nsCOMPtr<nsIWebBrowserChrome> browserchrome;
>
>         nsDynamicFunctionLoad nsFuncs[] = {
>                 {"XRE_InitEmbedding", (NSFuncPtr*)&XRE_InitEmbedding},
>                 {"XRE_TermEmbedding", (NSFuncPtr*)&XRE_TermEmbedding},
>                 {0, 0}
>         };
>
>         nsresult rv;
>         gtk_init (&argc, &argv);
>         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>         gtk_widget_show(window);
>
>         rv = XPCOMGlueStartup("/usr/lib/xulrunner-1.9/libxpcom.so");
>
>         if (NS_FAILED(rv)) {
>                 printf("XPCOMGlueStartup\n");
>         }
>
>         rv = XPCOMGlueLoadXULFunctions(nsFuncs);
>         if (NS_FAILED(rv)) {
>                 printf("XPCOMGlueLoadXULFunctions\n");
>         }
>
>         rv = NS_NewNativeLocalFile(nsEmbedCString("/usr/lib/
> xulrunner-1.9"), PR_FALSE, getter_AddRefs(libxul));
>         if (NS_FAILED(rv)) {
>                 printf("NS_NewNativeLocalFile\n");
>         }
>
>         rv = XRE_InitEmbedding(libxul, 0, 0, 0, 0);
>
>         if (NS_FAILED(rv)) {
>                         printf("Error XRE_InitEmbedding %d\n",rv);
>                 return -1;
>         }
>
>         webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
>         if (NS_FAILED(rv)) {
>                         printf("do_CreateInstance webBrowser\n");
>         }
>
>         browserSetup =  do_QueryInterface(webBrowser,&rv);
>                 if (NS_FAILED(rv)) {
>                   printf("do_QueryInterface browserSetup\n");
>                 }
>
>                 browserSetup->SetProperty
> (nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS,PR_TRUE);
>                 browserSetup->SetProperty
> (nsIWebBrowserSetup::SETUP_ALLOW_JAVASCRIPT,PR_TRUE);
>                 browserSetup->SetProperty
> (nsIWebBrowserSetup::SETUP_ALLOW_IMAGES,PR_TRUE);
>                 browserSetup->SetProperty
> (nsIWebBrowserSetup::SETUP_ALLOW_META_REDIRECTS,PR_TRUE);
>                 browserSetup->SetProperty
> (nsIWebBrowserSetup::SETUP_ALLOW_SUBFRAMES,PR_TRUE);
>                 browserSetup->SetProperty
> (nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER,PR_FALSE);
>
>         baseWindow = do_QueryInterface(webBrowser);
>
>         rv = baseWindow->InitWindow(window, 0, 0, 0, 1300, 700);
>         if (NS_FAILED(rv)) {
>                 printf("InitWindow\n");
>         }
>         rv = baseWindow->Create();
>         if (NS_FAILED(rv)) {
>                 printf("Create\n");
>         }
>         rv =baseWindow->SetVisibility(PR_TRUE);
>         if (NS_FAILED(rv)) {
>                 printf("SetVisibility\n");
>         }
>         webNavigation = do_QueryInterface(webBrowser);
>         rv = webNavigation->LoadURI(NS_ConvertASCIItoUTF16(argv[1]).get
> (),nsIWebNavigation::LOAD_FLAGS_NONE , 0, 0, 0);
>
>         if (NS_FAILED(rv)) {
>                 printf("LoadURI\n");
>         }
>         g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK
> (delete_event), 0);
>         gtk_main();
>         XRE_TermEmbedding();
>         XPCOMGlueShutdown();
>         exit(0);
>
> }

Firstly, sorry for repeat the same post many times, I thought there
was problems because the message didn't appear some time after send
it.
I resolve the javascript problem. I saw that nsIWebBrowserChrome is
the key.
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to