欢迎访问:常州市武进区嘉泽中心小学网站 !今天是:
栏目列表
您现在的位置是:首页>>教师>>计算机技术>>网站制作技术>>文章内容
XML + XSL + JS 构建小型Web App (十五)
发布时间:2008-11-20   点击:   来源:本站原创   录入者:佚名
 

4. index.htm.files/js/common.js

下面列出common.js 文件中 和显示功能相关的函数,其他函数后面详细叙述。

// 文件名 :common.js 
// 常用 javascript 函数的声明
// 作者 : 刘海龙
// xiaoleilong@{域名已经过期}
// 2003年8月1日

//初始化 需要显示的内容
function init()
{
 var coll = document.all.tags("DIV");
 var i;
 for (i=0;i<3;i++ )
  coll[i].style.display = "none"; 
 coll[0].innerHTML = do_trans("index.htm.files/data/record.xml","index.htm.files/styles/normal.xsl");//显示视图
 coll[1].innerHTML = get_edit_view();
 coll[2].innerHTML = get_set_view();
 
}
/** 函数 do_trans((strXmlPath , strXslPath)
   * 参数:分别指定 xml 文件 和 xsl 文件的路径
   * 功能:使用 xsl 对 xml 进行转换
   * 返回:转换得到的字符串
   */
function do_trans(strXmlPath , strXslPath)
{
    // Load XML
    var xml = new ActiveXObject("Microsoft.XMLDOM")
    xml.async = false
    xml.load(strXmlPath)
    // Load the XSL
    var xsl = new ActiveXObject("Microsoft.XMLDOM")
    xsl.async = false
    xsl.load(strXslPath)
    // Transform
 return xml.transformNode(xsl);
}

/** 函数 disp_spec_sect(section)
   * 参数:指定将切换到的页面 , 其中 : disp -- 显示简历的页面 ; edit -- 编辑简历的页面 ; set -- 进行基本设置的页面 。
   * 功能:根据 section 参数的取值, 切换显示到指定的页面 。
   * 返回:无返回值
   */
function disp_spec_sect(section)
{
 var coll = document.all.tags("DIV");
 if (coll != null)
 {
  for (i=0; i<coll.length; i++)
   coll[i].style.display = "none";
 }
 document.getElementById(section+"").style.display = "block";
}


附件:
    关闭窗口
    打印文档
    账号登录
    保持登录 忘记密码?
    账号与武进教师培训平台同步