1

I have a javascript file connected to my XUL file as follows:

<script type="application/javascript"
  src="chrome://myexample/content/myexample.js"/>

The overlay from the XUL file is displayed in Firefox, but my functions aren't working.

e.g.

<statusbar id="status-bar"> 
<statusbarpanel id="f1"  
    label="f1"
    onclick = "MyExample.f1()"
  />
</statusbar>

myexample.js file looks like:

var MyExample = {
  f1: function() {
  },
  f2: function() {
  }
}

This is my chrome.manifest:

content   myexample  content/
overlay chrome://browser/content/browser.xul  chrome://myexample/content/myexample.xul

Where could be the fault?

2 Answers 2

1
+50

There doesn't seem to be anything wrong with the code you posted, apart from the missing = in

var MyExample = {

...not sure if that's a typo in the original code or just in the snippet here.

Did you set the javascript.options.showInConsole and check the Error Console? Are there any messages there when you open the window you try to modify?

You could also be hitting the fact that the chrome code is cached. The effect is that the code you have in your file is not the same code that's running in Firefox. The way to deal with it is to set the disable_xul_cache pref mentioned on the same page as the showInConsole pref I linked to above (and/or run with -purgecaches param). If you have any doubts, make an observable change (i.e. one that has to change the observed behaviour, e.g. pops an alert) to the file you think is cached.

[edit] also you could try opening chrome://myexample/content/myexample.js in a tab to see if the chrome.manifest magic is working correctly and you got the URL right, but I guess in your case it's fine.

Sign up to request clarification or add additional context in comments.

8 Comments

It was a type in just snippet in the question :-(
Is it possible that firefox 8.0 doesn't allow unpacked extensions? When I try to open chrome://myexample/content/myexample.js it shows a message: Firefox can't find the file at jar:file:///home/xralf/.mozilla/firefox/pkebutrj.dev/extensions/[email protected]!/content/myexample.js. I will append chrome.manifest to the question.
minor note: disable_xul_cache is not in about:config
The error console reports that chrome://myexample/content/myexample.xul was not found. Yesterday I installed Firefox 8.0 and the extension does not display my XUL either. I guess that the error is in chrome.manifest, install.rdf and extension name, but I don't know what could be wrong. I installed it with install from file option.
(Re minor note: disable_xul_cache is not the full name and you have to add it to about:config manually.) You other question indicates a packaging mistake, but doesn't contain enough info. What's "install from file", did you mean you installed the xpi file from the addon manager? what's the xpi contents (unzip -l /home/xralf/.mozilla/firefox/pkebutrj.dev/extensions/myexample@xralf.‌​com.xpi)? Firefox tells you there's no ./content/myexample.js in the zip.
|
0

You dont need MyExample. part.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.