Single extension's object instance for all browser's windows?

 

Hi *,

I observed that each Firefox window creates its own instance of my
extension. Is any simple way to have single instance of some object 
shared by all browser's windows? within each window, I need to share object
between all windows.

In my example code as follow, the count should be increase with each window
, for example ,when I open three windows , the count should be shown "three"
when I open the third window.

In order to work out what I'm misunderstanding/doing wrong I'd be really
grateful if someone could help me ?

 

Javascript code :

 

        function start(){

           var countClass = loader.loadClass('testCount');

           this.countObj = countClass.newInstance();

           var str =this. countObj. showCount ();

          alert(str);

                

                }

window.addEventListener('load',function () { start ();}, false);     //when
open a new window , the count will be increase

 

 

JAVA code :

 

public class testCount {

    public int visitorCount;

          public testCount ()

            {

                visitorCount = 0;

            }

 

            public String showCount()

            {

                visitorCount++;

                return (new StringBuilder("Greetings, visitor number
")).append(visitorCount).append("!").toString();

            }

}

 

0
stefan
3/30/2010 3:58:14 AM
mozilla.dev.extensions 5694 articles. 0 followers. Post Follow

1 Replies
804 Views

Similar Articles

[PageSpeed] 3
Get it on Google Play
Get it on Apple App Store

On Mar 30, 5:58=A0am, "stefan.saye" <stefan.s...@gmail.com> wrote:
> Hi *,
>
> I observed that each Firefox window creates its own instance of my
> extension. Is any simple way to have single instance of some object
> shared by all browser's windows? within each window, I need to share obje=
ct
> between all windows.
>

I had a similar problem and found a solution (XPCOM), here is the old
thread:
http://groups.google.com/group/mozilla.dev.extensions/browse_thread/thread/=
aebbcc8728d34f17
In this thread, Eric Jung also suggested to use a "singleton JS" which
could be easier to use.

-Ulrich
0
Ulrich
3/30/2010 10:10:48 PM
Reply:

Similar Artilces:

Single extension's object instance for all browser's windows? #2
Hi *, I observed that each Firefox window creates its own instance of my extension. Is any simple way to have single instance of some object shared by all browser's windows? within each window, I need to share object between all windows. In my example code as follow, the count should be increase with each window , for example ,when I open three windows , the count should be shown "three" when I open the third window. In order to work out what I'm misunderstanding/doing wrong I'd be really grateful if someone could help me ? Javascript code : ...

Replace 1's and 0's in a gridview column with Yes's and No's
Is it possible to change the display of a column in a gridview to show a Yes for all 1's and a No for 0's that display in a particular column of a gridview bound to a database?  If so, can someone share the way with me?  I am using ASP.NET 2.0 with VB Code Behind.  Thanks One way you can do is thrrough  CASE in your select statement: Select YesNoColumn= CASE yourColumn WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END FROM YourtableLimno <Columns>     <asp:TemplateField HeaderText="yourHeader" SortExpression="yourDataField"> ...

It's Linux !? No, it's BSD ! No, no, it's...
kFreeBSD http://wiki.debian.org/Debian_GNU/kFreeBSD a Debian distro using the FreeBSD kernel ! ObiWan wrote: > kFreeBSD > > http://wiki.debian.org/Debian_GNU/kFreeBSD > > a Debian distro using the FreeBSD kernel ! Why use a BSD kernel? I hope the reason is more than, just because they can. http://wiki.debian.org/Debian_GNU/kFreeBSD_why It's easy to understand why the would want to use Debian packages. :) -- Jimmy Johnson Registered Linux User #380263 >> kFreeBSD >> >> http://wiki.debian.org/Debian_GNU/kFreeBSD >> ...

Help! I cannot access the DataGrid's ItemTemplate's LinkButton's Text Atrribute 's Value!!!!!!!!!!!
I write a datagrid's ItemDataBound method as follows:   private void dgTable_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)  {   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)   {    if(!isRole("Manager"))    {     LinkButton tmp = (LinkButton)e.Item.FindControl("lbPassed");     if(tmp.Text == "Passed")     {      ((LinkBu...

Hyperlink's, ImageURL's, and OnError's
I created an ASP:Hyperlink and set the ImageURL attribute so the link will be the image.If the image is missing, I would like it to display a 'missing image' pic that I have.  I know you can use the OnError attribute of the <img> tag to run some javascript to change it.Unfortunately I can't find a way to access the Hyperlink's Image that is inside it, so I can add an Attribute so the resulting <img> tag will have an OnError attribute inside of it.Any help?If my Hyperlink is called 'foo'....would I do...  ((Image) foo.Controls[0]).Attributes.Add(&...

Error 1 The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\asse
Once I build project. I encounter this error. Does someone experience this error?Error    1    The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35\System.Web.Extensions.dll'    D:\Source Code\Linq_Lesson5\Default.aspx    1    1    D:\Source Code\Linq_Lesson5\  It appears tha...

How to fix/limit asp:Panel's sizes to browser's window size?
I'm trying to develop a web page, which at a basic level, looks similar to the MSDN2 Library page (http://msdn2.microsoft.com/en-us/library/default.aspx).  That is, I have a left and right pane with the left pane being a fixed width, and the right pane is suppose to fill the rest of the browser window's width.  I'm utilizing asp:Panel controls for the two panes.  For the left pane, I've specified "position:absolute; left:0px, top:0px, bottom:0px; width:150; overflow:scroll;"  And for the right pane, I have "position:absolute; left:151; top...

Who's show is SN? Steve's or Leo's?
I don't want to start anything (honestly)! Just want to ask a simple question. Does the Security Now podcast belong to Steve Gibson or Leo Laporte? Maybe I'm in a world all to myself, but when I listen to the excellent SN podcasts, I want to hear STEVE, not Leo. But especially in the past few shows, it seems Leo will repeatedly interrupt Steve in the middle of a sentence that I want to hear the rest of. I consider this very rude of Leo. Steve is making a point that I (we) want to hear, then looses his train of thought after Leo barges in and asks something. It...

DataSet's DataTable's and TableAdapter's Oh My!
Here is my situation.  I am using VB as my programming language.I am creating a part of a website that will be the admin section.  I want the admin to be able to add/edit data in a set of tables that normal users can't.  There are 20 lookup tables that I use in the website that I want the admin to be able to manage (i.e. add, edit, delete, insert).  I don't want to create 20 separate web pages (one for each table).  I have one page that has links to all the tables.  Each link has a "table" querystring variable associated with it.  When the...

Guru's..?? Any do's and/or dont's for Zfd4 and Citrix..?
We've got a nw6/sp5 network with GW 6.5, bm3.7 and zfd 4.01 up'n'running.. Now we're adding a citrix server ( win2003) to the mix, will supply a couple off app's to users over the internal VPN in another city. Probably we'll skip the AD phase since we can not see any app and/or user with the need for AD. So,, any special considorations..? tip's'tricks..? known issues...? t.i.a... On Mon, 16 Aug 2004 15:57:10 GMT, Emerson wrote: > So,, any special considorations..? tip's'tricks..? known issues...? biggest one... zfd4.x d...

hi, how to export xul's js object to browser control's html context?
hi, man, In xul, we can embed <script></script> to execute js code to control xul UI, and I define some objects, want to let them accessable in html page in one browser control, how should I do? Thank you! Tang Daogang wrote: >In xul, we can embed <script></script> to execute js code to control xul UI, and I define some objects, want to let them accessable in html page in one browser control, how should I do? > Maybe this will help you: https://developer.mozilla.org/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages ...

411 it's pconsole, 51 it's NWPMW32, 65 it's ???
I like to give some of my users controll over their print jobs. In Netware 3.x to 4.x it was pconsole. In Netware 5.x it was NWPMW32. I don't seem to be able to find the same type of utility for Netware 6.5? We don't like to give user access to nwadmin and the NWPMW32 I copied from my 51 server (TID 10075273) to the 65 server won't display the jobs. Mmccabe, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try o...

Suggestion: 'Extension stability rating system to prevent firefox's public image from suffering from crashes due to extensions
Name: Michiel Wittkampf Email: michielwittkampf_at_gmail.com Product: Firefox Summary: Suggestion: 'Extension stability rating system to prevent firefox's public image from suffering from crashes due to extensions Comments: Hi, i'm a big fan of Firefox and have a suggestion with regard to firefox's public image, crashes and extensions. INTRODUCTION When I have some extensions installed Firefox crashes ones in a while. (According to the website this happens with more users, and I think this is logical part of extension development. Is it?). PROBLEM My po...

Web resources about - Single extension's object instance for all browser's windows? - mozilla.dev.extensions

Resources last updated: 12/13/2015 9:10:31 PM