一组sharepoint中组合各种功能的JavaScript

介绍下大概的功能:

raddio button 列变行的功能;

载入页面时候改变source的链接,这样就可以改变OKbutton的走向;

加入自定义按钮,根据页面选项,动态决定点击按钮之后页面,同时更新页面内容;

利用form action 按钮的提交功能更新页面,利用setTimeout在更新页面内容后异步导向新的页面链接。

<script type='text/javascript'>
  function AdjustTable(objTab)
{
  var tabArray = new Array();
  for(var i = 0;i<objTab.rows[0].cells.length;i++)
  {
   var tmpArray = new Array()
 for(var j = 0; j<objTab.rows.length;j++)
 {
  tmpArray[tmpArray.length] = objTab.rows[j].cells[i].outerHTML
 }
 tabArray[tabArray.length] = tmpArray;
  }
  var str = "";
 
  for(var i =0;i<tabArray.length;i++)
  {
   str += "<tr>" + tabArray[i].join("") + "</tr>"
  }
  str = "<table  id=\"tab\">" + str + "</table>";
 objTab.outerHTML = str
}
function Adjust()
{
var table1=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff1_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table1);
var table2=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff2_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table2);
var table3=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff3_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table3);
var table4=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff4_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table4);
var table5=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff5_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table5);
var table6=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff6_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table6);
var table7=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff7_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table7);
var table8=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff8_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table8);
var table9=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff9_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table9);
var table10=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff10_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table10);

var table0=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff34_1_ctl00_ctl00").parentNode.parentNode.parentNode.parentNode.parentNode;
AdjustTable(table0);

}
_spBodyOnLoadFunctionNames.push("Adjust");


 function GetQueryString(name)     
{     
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");     
     var r = window.location.search.substr(1).match(reg);     
     if (r!=null)
     {
      return unescape(r[2]);
     }
     else
     {
      return "";
     } 
}

function JudgePrevious()
{

 var ID=GetQueryString('ID');
 var lowrisk=document.getElementById("ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff17_1_ctl00_ctl00_TextField");
 var strUrl=window.location.href;
 var url=strUrl.substring(0,strUrl.lastIndexOf('/'));
   
 var btnHiddenSave=document.getElementById("btnHiddenSave");
 if(lowrisk.value=='1')
 {
    setTimeout("ChangeURL('EditRiskAssessment2.aspx')", 500);
    btnHiddenSave.click();
 }
 else
 {
    setTimeout("ChangeURL('EditRiskAssessmentDispensation.aspx')", 500);
    btnHiddenSave.click();
 }
 
}


function PreSaveAction()
{
     var ID=GetQueryString('ID');
     var lowrisk = document.getElementById('ctl00_m_g_e80015a3_8d3b_4fd2_abab_cce5971c2a8d_ff17_1_ctl00_ctl00_TextField');  

     if(lowrisk.value=='0')
     {
       return true;
     }   
    setTimeout("ChangeURL('EditProtectControlLR.aspx')", 500);
   
    var btnHiddenSave=document.getElementById("btnHiddenSave");
    btnHiddenSave.click();
}

function ChangeURL(url)
{
var ID=GetQueryString('ID');
window.location.href=url+'?ID='+ID;
}
function SetFields()
{
    var ID=GetQueryString('ID');
    if(window.location.href.indexOf('Source')<=0)
    {
      var strUrl=window.location.href;
      var url=strUrl.substring(0,strUrl.lastIndexOf('/'));  
      window.location.href=window.location+"&Source="+url+"/EditProtectControlNLR.aspx?ID="+ID;
    }   
}
 

SetFields();
</script>

posted on 2011-05-27 10:54  catvi  阅读(514)  评论(0编辑  收藏  举报

导航