[Project_owners] obtaining reference to new tab

Eric H. Jung grimholtz at yahoo.com
Tue Dec 6 14:17:51 EST 2005


Hi Didier,

Is there a full example of this in inforss or elsewhere? The following
doesn't work (perhaps I need a web progress listener to  wait until
STATE_STOP?)

var wm = Components
  .classes["@mozilla.org/appshell/window-mediator;1"]
  .getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
win = win.open("about:blank");
win.setAtribute("src","data:text/html;charset=utf-8,<html><body><p>helloworld</p></body></html>");

Thanks,
Eric

--- Didier Ernotte <didier at ernotte.com> wrote:

> Hi,
> 
> I've never succeded in changing the content of a browser dynamically
> with FF 1.5 (works fine with FF 1.0). The only way I have found
> (thanks
> to this mailing list...) is to use
> 
>           br.setAttribute("src",
> "data:text/html;charset=utf-8,<html><body>" + str +
> "</body></html>");
> 
> br is my browser object.
> 
> Didier
> 
> --- "Eric H. Jung" <grimholtz at yahoo.com> wrote:
> 
> > OK, so I have this to create a new, empty tab and then insert
> > content:
> > 
> > var wm = Components
> >   .classes["@mozilla.org/appshell/window-mediator;1"]
> >   .getService(Components.interfaces.nsIWindowMediator);
> > 
> > var win = wm.getMostRecentWindow("navigator:browser");
> > win.gBrowser.selectedTab = win.gBrowser.addTab("about:blank");
> > var content = "<html><body><p>hello, wurld</p></body></html>";
> > var dom = new DOMParser().parseFromString(content, "text/xml"); 
> > win.gBrowser.selectedTab.appendChild(dom.documentElement);
> > 
> > The string-to-DOM code works fine, but nothing appears in the new
> tab
> > after executing the appendChild() call. Should I call this on some
> > child or parent of win.gBrowser.selectedTab?
> > 
> > Thank you again,
> > Eric Jung
> > 
> > 
> > 
> > --- Adam Judson <adamsplugins at gmail.com> wrote:
> > 
> > > I'm using this:
> > > 
> > 
> > > 
> > > 
> > > A
> > > 
> > > 
> > > On 06/12/05, Eric H. Jung <grimholtz at yahoo.com> wrote:
> > > > Hi,
> > > >
> > > > I'm using this code to open a new, empty tab. How can I get a
> > > reference
> > > > to the new tab so I can insert content? window.open() returns a
> > > > reference to the new window, but I don't know how to get a
> > similar
> > > > reference for a new tab. Any ideas?
> > > >
> > > > var wm = Components
> > > >   .classes["@mozilla.org/appshell/window-mediator;1"]
> > > >   .getService(Components.interfaces.nsIWindowMediator);
> > > > var recentWindow = wm.getMostRecentWindow("navigator:browser");
> > > > if (recentWindow)
> > > >   recentWindow.delayedOpenTab("about:blank");
> > > >
> > > > Thank you,
> > > > Eric Jung
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________________
> > > > Yahoo! DSL – Something to write home about.
> > > > Just $16.99/mo. or less.
> > > > dsl.yahoo.com
> > > >
> > > > _______________________________________________
> > > > Project_owners mailing list
> > > > Project_owners at mozdev.org
> > > > http://mozdev.org/mailman/listinfo/project_owners
> > > >
> > > > _______________________________________________
> > > Project_owners mailing list
> > > Project_owners at mozdev.org
> > > http://mozdev.org/mailman/listinfo/project_owners
> > > 
> > 
> > 
> > 
> > 		
> > __________________________________________ 
> > Yahoo! DSL – Something to write home about. 
> > Just $16.99/mo. or less. 
> > dsl.yahoo.com 
> > 
> > _______________________________________________
> > Project_owners mailing list
> > Project_owners at mozdev.org
> > http://mozdev.org/mailman/listinfo/project_owners
> > 
> 
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
> 



		
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 



More information about the Project_owners mailing list