Conditional inclusion of JS for cross-browser extension (was Re: [Project_owners] Extension works only once on FF 1.5)

Sudhakar Chandra thaths at openscroll.org
Wed Nov 30 19:48:34 EST 2005


Hi,

I have isolated where the problem is occurring. On top of my XUL I have
the following:

<script type="application/x-javascript">alert("Inside XUL");</script>

<script type="application/x-javascript"
src="chrome://browser/content/bookmarks/bookmarks.js"/>

<script type="application/x-javascript">alert("Checkpoint 0");</script>
<script type="application/x-javascript"
src="chrome://communicator/content/bookmarks/bookmarks.js"/>
<script type="application/x-javascript">alert("Checkpoint 1");</script>
<script type="application/x-javascript"
src="chrome://global/content/strres.js"/>
<script type="application/x-javascript">alert("Checkpoint 2");</script>

The first time I load my extension, there is an warning message printed
into JS Console but the extension loads just fine. The execution takes
me through all the checkpoints 0, 1 and 2. However, the second time I
try to run my extension, the execution only reaches up to Checkpoint 0.
The execution never reaches Checkpoint 2.

I understand why this is happening - chrome://communicator/... does not
exist in Firefox. It is a Mozilla thing.

However, my problem is that I want my application to run both inside
Firefox and Mozilla. How do I conditionally include
chrome://browser/.../bookmarks.js for FF and
chrome://communicator/.../bookmarks.js for Mozilla?

Is there a more elegant way of doing this than a conditional (if()) with
document.write("<script...")?

Thanks.

Thaths

Gareth Hunt wrote:
> Hi Thaths,
> 
> Have you looked in the javascript console to see if there are any
> errors?  Tools -> Javascript Console
> 
> I saw something like this before and it was a javascript error caused
> by a missing preference not stored after the initial run.
> 
> Gareth
> 
> --- Sudhakar Chandra <thaths at openscroll.org> wrote:
> 
>>Hi,
>>
>>My extension (habarixenu.mozdev.org) works the first time it is
>>launched
>> in Firefox 1.5 - it opens up a chrome xhtml file in a new tab where
> 
> a
> 
>>chrome xul file is opened inside an frame. But when I close this tab
> 
> and
> 
>>try to relaunch the application, the xhtml loads but not the xul. I
> 
> have
> 
>>tried typing in the chrome://  url of the xhtml or the xul directly
> 
> and
> 
>>still the xul does not load. This happens only with FF 1.5. The
>>extension works fine with FF 1.0.7 any number of times.
>>
>>Thanks.
>>
>>Thaths
> 
> 
> 
> Gareth Hunt
> gareth-hunt at rocketmail.com
> 
> 
> 		
> ___________________________________________________________ 
> To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
> 

-- 
"Anyone who believes in telekinesis, raise my hand." -- Kurt Vonnegut
Slacker Without Borders                        http://openscroll.org/
Key fingerprint = 8A 84 2E 67 10 9A 64 03  24 38 B6 AB 1B 6E 8C E4


More information about the Project_owners mailing list