ITPub博客

首页 > 应用开发 > IT综合 > XML + XSL + JS 构建小型Web App (十五) (转)

XML + XSL + JS 构建小型Web App (十五) (转)

原创 IT综合 作者:gugu99 时间:2007-08-16 13:10:05 0 删除 编辑
XML + XSL + JS 构建小型Web App (十五) (转)[@more@]

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

下面列出common.js 文件中 和显示功能相关的函数,其他函数后面详细叙述。
XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office:office" />

// 文件名 :common.js 
// 常用 Javascript 函数的声明
// 作者 : 刘海龙
// to:xiaoleilong@mail.biti.edu.cn">xiaoleilong@mail.biti.edu.cn
// 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[i].style.display = "none";
 }
 document.getElementById(section+"").style.display = "block";
}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10748419/viewspace-961548/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3121
  • 访问量
    2644405