Sharing Javascript code between eSpaces

Sharing Javascript code between eSpaces

  
Hi,

To be able to reuse Javascript between several eSpaces withou having to create a special webblock and referencing it on every page...:


1. Put this javascript on your eSpace javascript. This is probably the only code you'll need there.

var html_doc = document.getElementsByTagName('head').item(0);
var js = document.createElement('script');
js.setAttribute('language', 'javascript');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', 'JSInclude.js');
html_doc.appendChild(js);


2. Add a reference to the extension JSInclude.xif (see attached file)


By doing this you won't have to copy to your eSpace those functions such as goSetHeight(), goSetHeight2(), Scriptaculous stuff and so on... any more.

You'll also be able to manage more effectively all of these JS functions because they will be on a single file within the extension. Every time we need to add, for instance, a popup function that should be available for everyone, we just need to add it within this extension. And we'll also have a clear overview of who's using those functions (at least consuming it).

Note: this extension has been saved with Integration Studio 3.1.


Duarte Gouveia