WEB开发网
开发学院网页设计JavaScript 在Javascript中调用WSS---下 阅读

在Javascript中调用WSS---下

 2010-09-14 13:43:17 来源:WEB开发网   
核心提示: 顺便给出一个调用的例子: 1 var rootUrl = window.location.protocol + "//" + window.location.host;2 var contractId = getUrlParam("ID");3 va

顺便给出一个调用的例子:

  1 var rootUrl = window.location.protocol + "//" + window.location.host;
 2 var contractId = getUrlParam("ID");
 3 var contractName = getContractNameById(rootUrl, contractId);
 4 alert(contractName);
 5
 6 function getContractNameById(baseUrl, id)
 7 {
 8     var lists = new SPAPI_Lists(baseUrl);
 9     var items = lists.getListItems(
10     'Contract',
11     '',
12     '<Query><Where><Eq><FieldRef Name="ID"/><Value Type="Counter">' + id + '</Value></Eq></Where></Query>',  // query
13     '<ViewFields><FieldRef Name="Title"/></ViewFields>',
14     1,  // rowLimit
15     ''  // queryOptions
16     );
17
18     if (items.status == 200)
19     {
20         var rows = items.responseXML.getElementsByTagName('z:row');
21
22         if (rows.length == 1)
23         {
24             return rows[0].getAttribute('ows_Title');
25         }
26         else
27         {
28             return null;
29         }
30     }
31     else
32     {
33         return null;
34     }
35 }
36
37 function getUrlParam(name)
38 {
39     var query = window.location.search.substring(1);
40     var pairs = query.split("&");
41     var argname = "";
42     var val = "";
43     for (var i = 0; i < pairs.length; i++)
44     {
45         var pos = pairs[i].indexOf('=');
46         if (pos == -1)
47         {
48             continue;
49         }
50         argname = pairs[i].substring(0, pos);
51         val = pairs[i].substring(pos + 1);
52         val = decodeURIComponent(val);
53         if (argname == name)
54         {
55             return val;
56         }
57     }
58     return null;
59 }

上一页  1 2 

Tags:Javascript 调用 WSS

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接