当前位置:开发者网络 >> 网页特效 >> 页面特效 >> 内容
精彩推荐
分类最新特效
分类热点特效
  
自动识别网页文件类型
日期:2005-06-10   人气:   【字体: 】【收藏此文


<!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! -->
<!-- 要实现此效果需要 2 个步骤: -->

<!-- 第 1 步: -->
<!-- 把下面的代码加到<HEAD></HEAD>区域中: -->


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
URL = window.location.href;
ishtm = (URL.indexOf('.htm') > -1);
ishtml = (URL.indexOf('.html') > -1);
isshtml = (URL.indexOf('.shtml') > -1);
isphtml = (URL.indexOf('.phtml') > -1);
// End -->
</script>



<!-- 第 2 步: -->
<!-- 把下面的代码加到<BODY></BODY>区域中: -->

<center>
<SCRIPT LANGUAGE="JavaScript">
if (isphtml) {
document.write("这是一个 .phtml 文件!");
}
else if (isshtml) {
document.write("这是一个 .shtml 文件!");
}
else if (ishtml) {
document.write("这是一个 .html 文件!");
}
else if (ishtm) {

document.write("这是一个 .htm 文件!");
// Include the generic .htm last because if tested
// first, it would be true for all the file types above

}
else {
document.write("无法识别该类文件.");
}
</script>
</center>