Making widgets - inserting dialogs into HTML page. Step by Step experiments.

We call:
   widget   - small JS code which is written in hostpage, 
   injector - arbitrarily big JS code which is not a part of hostpage text and is attached to hostpage by through widget.

Approach1 - works but breaks idea of incapsulation of name "this".

Approach2 - started all over.

Approach3 - started all over. No AJAX. Google-like style of crossdomain.

Movements - Dynamic via JS and CSS.

I n s e r t i o n   m e t h o d s.  Draft.

Here are the differences in injection:

L. wrap_to_load_event                        - "fastload"           - seems the most traditional
T. wrap_to_setTimeout_event                  - "locationproof"      - snippet can be in the header,
F. free, don't wrap into any event:
   variants: F.N. attach to document's node as node <script>
             F.T. directly insert into text:
                  F.T.L - load from link or scr in <script src="insertme.js" >  </script>
                  F.T.W - write immediately <script> element  Sample apparently from Google

All methods are different only in hostpage, injector can be the same.

In L, snippet is wrapped in window.load event:
 advantage: will load fast after hostpage is loaded.
 disadvantage: if hostpage master put another script after which erases window.load event, our snippet should never appear.
 In other words, this solution is not very foolproof.

In T, the delay interval can be make arbitrarily big:
 advantage: snipped can be safely put at any place on hostpage.
 disadvantages: Possibly long initial delay, desirably 20 seconds for slow loading hostpages.
                It is hard to estimate short delay.

F.N works OK with all but perhaps not in IE browsers. 
    disadvantage: possibly incorrect insertion syntax making widjet load unpredictable and 
                apparently causing IE to give a hidden warning without breaking
                functionality when user returns from target page.

F.T, F.N - apparently user browser has to wait while executing script, but foolproof: no competition for on-load event.

F.N    Following will be asynchronous when browserw will support 'async' attribute. Until then, it is immediate:
                  (function() {
                   ...  document.createElement('script');
                   ...  ('https:' == document.location.protocol ? 'https://ssl' : ...
                   ... setAttribute('async', ... 
                   ... documentElement.firstChild.appendChild( ...