summaryrefslogtreecommitdiff
path: root/httemplate/elements/rs_init_object.html
blob: ec44d439abe68aeed06008011876f2ed1cf359bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<%doc>

The rs_init_object javascript function defined by this include instantiates and
returns a new object for XMLHTTP communication: on Microsoft browsers, an
ActiveXObject ("Msxml2.XMLHTTP" or "Microsoft.XMLHTTP"), or on other browsers,
an XMLHttpRequest object.

Example:

  <& /elements/rs_init_object.html &>

</%doc>
<%shared>
my $initialized = 0; #won't work if component is "preloaded"... so don't do that
</%shared>
% if ( ! $initialized++ ) {
<SCRIPT TYPE="text/javascript">

  function rs_init_object() {
    var A;
    try {
      A=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        A=new ActiveXObject("Microsoft.XMLHTTP");
      } catch (oc) {
        A=null;
      }
    }
    if(!A && typeof XMLHttpRequest != "undefined")
      A = new XMLHttpRequest();
    if (!A)
      alert("Can't create XMLHttpRequest object");
    return A;

  }

</SCRIPT>
% }