javascript - how to add/include js file in xbl? -
i've read around , found techniques add js file inside xbl, techniques don't work. tried declare tag: <'script src='test.js''>
, <'script src='chrome://content/test.js '>
, none worked.
the method inside test class function caller() { alert("call succeeded"); }
.
is there correct , simple way include js file inside xbl, calling functions file works if function written inside xbl.
here's more details: http://www.w3.org/tr/xbl-primer/#scripts you're doing seems fine, here's example they're giving:
<xbl xmlns="http://www.w3.org/ns/xbl"> <script src="example.js"/>
note xmlns there, that's default namespace. if have defined as: xmlns:xbl="http://www.w3.org/ns/xbl" have use
<xbl:script src="example.js" />
try that, never tried myself namespace thing common pitfall.
edit: i'm afraid might not possible. xbl 2.0 spec, , gecko doesn't seem supporting yet, , in xbl 1.0 script tag not exist:
http://groups.google.com/group/mozilla.dev.tech.xbl/msg/d7d4f279ebdad65f?pli=1 mentioning here development should full swing.
here's link pointing to: https://wiki.mozilla.org/xbl2 seems hasn't been updated since 2009, it's hard tell if going implemented.
and here's xbl 1.0 reference can see script tag not exist: https://developer.mozilla.org/en/xbl/xbl_1.0_reference
but offer possible alternative - use modules, , in constructor this:
<constructor> components.utils.import("resource://yourextension/config.js");
for more on modules: https://developer.mozilla.org/en/javascript_code_modules , example: https://developer.mozilla.org/en/javascript_code_modules/using you'd need register modules folder put test.js in it, follow instructions how "export" functions/variables it. can import javascript, xul or xbl file.
Comments
Post a Comment