This page is a first draft, which will be revised and improved. Please leave us a note on the community page regarding any issue.
Background Code
The Background Code will be executed at the background only once (unlike main code which is running on each page) and will live as long as your extension is running.
Background code is usually used to be the focal point of browser integration (such as toolbar button, omnibox, etc.) and global management of tabs functionality.
Crossrider framework gives every developer easy developing tools to achieve a full-on cross-browser extensions using regular Javascript. That means you can write simple JS code that will run on different browsers as extension, without the hassle of taking care of each browser specific requirements and different procedures.
e.g.: I would like to access the DOM of a page (of a tab, not the page "background.html") via the JS document.getElementById method... it would be useful if I can share some variables between extension.js and background.js...
The best way to access the DOM is from the Page Code.
You can access it with jQuery selectors with the built in Crossrider $jquery object.
As you found out by yourself already, if you wish to send messages from the background code and then read the DOM, you can use the messaging API, which is demonstrated at this Demo App: (You need to be logged in to Crossrider to view it)
http://crossrider.com/apps/90/view
p.s - We will soon add more detailed information on the Messaging API on the wiki.
is it possible to include files like css and .js in the background? instead of loading these on each page
thx
This question is related more to the @include section (https://crossrider.wiki.zoho.com/Include-Exteral-Files.html) rather then the background code.
The @include directives do, as you said, load the css and js on every page synchronously but you need to be aware to the fact that once they have been saved in the browser cache these actions are super-fast.
If however you do want to do async calls to any js or css file you can use the cross domain request API (https://crossrider.wiki.zoho.com/Cross-Domain-Requests.html).
But you must be aware that usually JS is loaded on the page synchronously do avoid code dependencies issues.
Email me to shmueli@crossrider.com if you need any further assistance with this.
"Note: Background code is currently not available in IE."
So there is no use of the background code in IE or?