0

0

OfficeXP_menu过程版_PHP教程

PHP中文网

PHP中文网

发布时间:2016-07-13 17:24:27

|

1241人浏览过

|

来源于php中文网

原创

<?php
/**
* 仿officexp风格的左边版面列表    
* --------------------------------------------------------------------------------
* blood 于 2/19/2002 4:47:11 pm 加贴在 visual basic
*
* 徐祖宁(唠叨) 移植于 2/28/2002
* 更正部分错误
*
*/

if($key == ""):
echo <<<eod
<html>
<head>
<title>menu sample</title>
<script language="javascript"> 
if (window != top) top.location.href = location.href;
</script>
</head>
  <frameset cols="161,*">        
    <frame marginwidth="0" src="$php_self?key=menu" name="menu" scrolling=no noresize>
    <frame  marginwidth="0" src="$php_self?key=about" name="main" scrolling=auto noresize>
  </frameset>
</html>
eod;
endif;

if($key == "menu"):
/**
*
* $menuon                      定义分类菜单数目
* $menubackcolor               定义分类菜单背景颜色
* $menufontsize                定义分类菜单字体
* $menubarheight               定义分类菜单高度
* $itemtextcolor               定义分类菜单项目文字颜色
* $itembackcolor               定义分类菜单项目背景颜色
* $topmenuheight               定义分类菜单与顶部的间距
* $selecteditemdarkborder      定义分类菜单项目在鼠标移动到上面时的暗边框颜色
* $selecteditemlightborder     定义分类菜单项目在鼠标移动到上面时的亮边框颜色
* $selecteditembackgroundcolor 定义分类菜单项目在鼠标移动到上面时的背景颜色
* $menusubsectionbackcolor     定义二级菜单背景颜色
* $menusubsectionfontcolor     定义二级菜单菜单字体颜色
* $deftarget                   定义菜单项目超连接默认目标框架
*/
$topmenuheight = 0;           //设置分类菜单与顶部的间距
$menubarheight = 20;          //设置分类菜单高度
$menufontsize = "9pt";            //设置菜单字体大小

//我们使用仿office xp风格的外观,也可以使用普通外观。
$menu_mode = false;

if($menu_mode) {
  //普通菜单外观
  $menubackcolor = "lightgrey";             //设置背景颜色
  $itembackcolor = "#7f7f7f";               //设置菜单项目背景色
  $itemtextcolor = "#ffffff";               //设置菜单项目文字颜色
  $selecteditemdarkborder = "#ffffff";      //设置菜单项目在鼠标移动到上面时的暗边框颜色
  $selecteditemlightborder = "#000000";     //设置菜单项目在鼠标移动到上面时的亮边框颜色
  $selecteditembackgroundcolor = "";        //设置菜单项目在鼠标移动到上面时的背景颜色
  $menusubsectionbackcolor = "lightgrey";   //设置二级菜单背景颜色
  $menusubsectionfontcolor="black";          //设置二级菜单字体颜色
}else {
  //仿office xp风格外观
  $menubackcolor = "lightgrey";             //设置背景颜色
  $itembackcolor = "lightgrey";             //设置菜单项目背景色
  $itemtextcolor = "#000000";               //设置菜单项目文字颜色
  $selecteditemdarkborder = "#08246b";      //设置菜单项目在鼠标移动到上面时的暗边框颜色
  $selecteditemlightborder = "#08246b";     //设置菜单项目在鼠标移动到上面时的亮边框颜色
  $selecteditembackgroundcolor = "#b5bed6"; //设置菜单项目在鼠标移动到上面时的背景颜色
  $menusubsectionbackcolor = "darkgray";    //设置二级菜单背景颜色
  $menusubsectionfontcolor = "black";       //设置二级菜单字体颜色
}
$deftarget = "main";    //设置菜单项目超连接默认目标框架

echo <<<eod
<style>
td { font-size: $menufontsize; font-family:"verdana", "arial", "宋体"; }
</style>
<body leftmargin=0 topmargin=0 rightmargin=0 bgcolor="$menubackcolor">
eod;

$menuon = 0;             //对菜单数目初始化

/**
* 绘制菜单方法:
* menustartsection($seq, $label)
*   制作分类菜单
*   $seq = 分类菜单序列号,使用菜单序列号控制启动是显示顺序
*   $label = 分类菜单标题
* menuadditem($label, $description, $url, $target="")
*   制作菜单项目
*   $label = 项目标题
*   $description = 项目简介
*   $url = 超连接地址
*   $target = 超连接目标框架,默认为$deftarget
* menuaddsubsection($label)
*   制作二级分类菜单。
*   $label = 二级分类菜单标题
* menuaddsubsectionline()
*   制作项目分割线,使用高度为2的图片
* menuendsection()
*   分类菜单结束
* menusectionasitem($label, $description, $url, $target="")
*   制作带超连接的分类菜单,类似菜单项目,可以直接使用
*   $label = 分类菜单标题
*   $description = 分类菜单简介
*   $url = 超连接地址
*   $target = 超连接目标框架,默认为$deftarget
*/

/**
* 函数定义
*/
function menuadditem($itemlabel, $statustext, $url, $target="") {
  global $deftarget,
         $selecteditemdarkborder,
         $selecteditemlightborder,
         $itemtextcolor,
         $selecteditembackgroundcolor,
         $menufontsize ;
  if($target == "") $target = $deftarget;
  $url = rawurldecode($url);
  echo <<<eod

<tr><td width="100%" align=left style="cursor:hand;" title="$statustext" onmouseover="this.bordercolordark=$selecteditemdarkborder;this.bordercolorlight=$selecteditemlightborder;this.style.backgroundcolor=$selecteditembackgroundcolor;this.style.color=black;status=$statustext;" onmouseout="this.bordercolordark=;this.bordercolorlight=;this.style.backgroundcolor=;status=;" onclick="window.open($url,$target);"><font color="$itemtextcolor">$itemlabel</font></td></tr>
eod;
}

function menuaddsubsection($itemlabel) {
  global $menusubsectionbackcolor,
         $menufontsize,
         $menusubsectionfontcolor;
  echo <<<eod

<tr bgcolor="$menusubsectionbackcolor"><td align=center width="100%"><font color="$menusubsectionfontcolor">$itemlabel</font></td></tr>
eod;
}

function menuaddsubsectionline() {
  echo <<<eod

<tr valign="center">
  <td align=center width="100%" height="2" bgcolor="white">
    <table border=0 cellspacing=0 cellpadding=0 width="100%" height="1">
     <tr valign="center" height="2">
       <td bgcolor="white"></td>
     </tr>
    </table>
  </td>
</tr>
eod;
}

function menusectionasitem($sectionseq, $sectionname, $sectiondesc, $url, $target="") {
  global $deftarget,
         $menubackcolor,
         $menubarheight,
         $menufontsize;
  if($target == "") $target = $deftarget;
  $url = rawurldecode($url);
  $mh = $menubarheight-2;
  echo <<<eod

<table border=0 cellspacing=0 cellpadding=0 width="100%" height="1">
<tr valign="center" height="1">
  <td bgcolor="white"></td>
</tr>
</table>
<table bgcolor="$menubackcolor" border=1 cellspacing=0 cellpadding=0 bordercolor="$menubackcolor" width="100%" height="smh">
<tr height="100%" valign="center">
  <td border=3 valign="middle" width="100%" height="100%" bordercolordark=lightgrey bordercolorlight=lightgrey align=center style="cursor:hand;" title="$sectiondesc" onmouseover="status=$sectiondesc;" onmouseout="status=;" onclick="window.open($url,$target);"><font color="#000000">$sectionname</font></td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=0 width="100%" height="1">
<tr height="1">
  <td bgcolor="black"></td>
</tr>
</table>
eod;
}

function menustartsection($sectionseq, $sectionname) {
  global $menubackcolor,
         $menubarheight,
         $menufontsize,
         $menusection,
         $itembackcolor;
  $mh = $menubarheight-2;
  echo <<<eod

<table bgcolor="$menubackcolo" border=0 cellspacing=0 cellpadding=0 width="100%" height="1">
<tr height="1">
  <td bgcolor="white"></td>
</tr>
</table>
<table bgcolor="$menubackcolor" border=1 cellspacing=0 cellpadding=0 bordercolor="$menubackcolor" width="100%" height="$mh">
<tr valign="center" height="100%">
  <td nowrap border=3 width="100%" height="100%" bordercolordark=lightgrey bordercolorlight=lightgrey align=center style="cursor:hand;" title="$sectionname" onmouseover="status=$sectionname;" onmouseout="status=;" onclick="startsection(menusection$sectionseq);">$sectionname</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=0 width="100%" height="1">
<tr height="1">
  <td bgcolor="black"></td>
</tr>
</table>
<div name=menusection$sectionseq id=menusection$sectionseq style="display:none;overflow:hidden; height:1px;marginright:0px;">
<table bgcolor=$itembackcolor style="marginright=0px;" border=1 cellspacing=0 cellpadding=0 bordercolor="$itembackcolor" width="100%">
eod;
}

function menuendsection() {
  echo <<<eod

</table>
</div>
eod;
}

/**
* 创建菜单
*/
  menustartsection(2, "代码世界");
  menuadditem("joy asp", "欢迎访问joy asp", "$php_self?key=page&id=joy asp");
  menuadditem("java 世界", "欢迎访问java 世界", "$php_self?key=page&id=java 世界");
  menuadditem("dotnet 时代", "欢迎访问dotnet 时代", "$php_self?key=page&id=dotnet 时代");
  menuadditem("visual basic", "欢迎访问visual basic", "$php_self?key=page&id=visual basic");
  menuadditem("delphi", "欢迎访问delphi", "$php_self?key=page&id=delphi");
  menuendsection();

  menustartsection(3, "开心一刻");
  menuadditem("传统笑话", "传统笑话", "$php_self?key=page&id=传统笑话");
  menuadditem("近代笑话", "近代笑话", "$php_self?key=page&id=近代笑话");
  menuaddsubsection("儿童类");
  menuadditem("校园笑话", "校园笑话", "$php_self?key=page&id=校园笑话");
  menuadditem("幼儿笑话", "幼儿笑话", "$php_self?key=page&id=幼儿笑话");
  menuadditem("少年笑话", "少年笑话", "$php_self?key=page&id=少年笑话");
  menuaddsubsectionline();
  menuadditem("中学时代笑话", "中学时代笑话", "$php_self?key=page&id=中学时代笑话");
  menuaddsubsection("成人笑话");
  menuadditem("带颜色的笑话", "带颜色的笑话", "$php_self?key=page&id=带颜色的笑话");
  menuadditem("笑话林", "笑话林", "$php_self?key=page&id=笑话林");
  menuendsection();

  menusectionasitem(3, "菜单简介", "菜单简介", "$php_self?key=about");

  menustartsection(1, "个人收藏夹");
  menuadditem("dotnet 时代", "欢迎访问dotnet 时代", "$php_self?key=page&id=dotnet 时代");
  menuendsection();

  // 将个人收藏夹定为启动菜单
  $menuon = 4;

/**
* 输出javascript脚本
*/
echo <<<eod

<script language=javascript>
var availheight       // 定义可利用的高度
var lastsection       // 定义将要打开的菜单关闭
var thissection       // 定义当前需要打开的菜单
var timerdelay=15     // 定义并设置延时
var menuactive=false  // 测定当前活动的菜单
var visibleheight     // 定义显示高度,确定是否显示滚动条
var aniratio          // 定义菜单显示滑动的速度

function getsizing() {
  // 菜单打开时得到的可利用的高度
  availheight=document.body.clientheight-$topmenuheight-($menubarheight*$menuon)
  if(availheight<=0) {
    lastsection.style.display=none;
  }else {
    // 改变菜单显示滑动速度的比率
    aniratio=0.75;                          // 设定速度
    if(availheight>200) {aniratio=0.667;}  
    if(availheight>500) {aniratio=0.5;}    // 根据可利用高度调整速度
    lastsection.style.height=availheight;
    lastsection.style.overflow=visible;
    lastsection.style.display=;
    visibleheight=parseint(lastsection.clientheight);
    if(visibleheight>availheight) {lastsection.style.overflow=auto;}else{lastsection.style.overflow=hidden;};
  }
}

function slidemenu() {
  // 菜单滑动函数
  if(parseint(lastsection.style.height)>1) {
    lastsection.style.height=parseint(parseint(lastsection.style.height)*aniratio);
    thissection.style.height=availheight-parseint(lastsection.style.height);
    var movetimer=settimeout("slidemenu()",timerdelay)  ;
  }else {
    // 完成菜单滑动,显示新打开的菜单,隐藏前面以打开的菜单
    lastsection.style.display=none;
    thissection.style.height=availheight;
    menuactive=false;
    if (visibleheight>availheight) {thissection.style.overflow=auto;};
    thissection.style.marginright=0;
    lastsection=thissection;
    cleartimeout(movetimer);
  }
}

function startsection(thesection) {
  // 开始滑动菜单,检测是否对菜单进行单击
  if(menuactive==false) {
    if(lastsection!=thesection) {
      menuactive=true;
      thissection=thesection;
      lastsection.style.overflow=hidden;
      thissection.style.overflow=visible;
      thissection.style.display=;
      visibleheight=parseint(thissection.clientheight);
      thissection.style.overflow=hidden;
      thissection.style.display=none;
      thissection.style.height=1;
      lastsection.style.height=availheight-1;
      lastsection.style.display=;
      thissection.style.display=;
      slidemenu()
    }
  }
}

window.onresize=getsizing
// 启动时打开默认的序号为第一个的菜单
lastsection=document.all.menusection1;
lastsection.style.display=;
getsizing();
</script>
</body>
eod;

endif;


if($key == "page"):
echo <<<eod
<style>
body { font-size: 9pt; font-family:"verdana", "arial", "宋体"; }
</style>
<body>
<center>
<br>
<br>
欢迎访问 $id
</center>
</body>
eod;
endif;

if($key == "about"):
echo <<<eod
<style>
body { font-size: 9pt; font-family:"verdana", "arial", "宋体"; }
</style>
<body>
<center>
<br>
<br>
关于此菜单
<br>
<br>
说明,此菜单程序只能使用在ie 5以上的版本使用,netspace下不能使用,推荐使用ie 6正式中文版
</center>
</body>
eod;
endif;
?>

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法

本专题系统整理pixiv网页版官网入口及登录访问方式,涵盖官网登录页面直达路径、在线阅读入口及快速进入方法说明,帮助用户高效找到pixiv官方网站,实现便捷、安全的网页端浏览与账号登录体验。

463

2026.02.13

微博网页版主页入口与登录指南_官方网页端快速访问方法
微博网页版主页入口与登录指南_官方网页端快速访问方法

本专题系统整理微博网页版官方入口及网页端登录方式,涵盖首页直达地址、账号登录流程与常见访问问题说明,帮助用户快速找到微博官网主页,实现便捷、安全的网页端登录与内容浏览体验。

135

2026.02.13

Flutter跨平台开发与状态管理实战
Flutter跨平台开发与状态管理实战

本专题围绕Flutter框架展开,系统讲解跨平台UI构建原理与状态管理方案。内容涵盖Widget生命周期、路由管理、Provider与Bloc状态管理模式、网络请求封装及性能优化技巧。通过实战项目演示,帮助开发者构建流畅、可维护的跨平台移动应用。

64

2026.02.13

TypeScript工程化开发与Vite构建优化实践
TypeScript工程化开发与Vite构建优化实践

本专题面向前端开发者,深入讲解 TypeScript 类型系统与大型项目结构设计方法,并结合 Vite 构建工具优化前端工程化流程。内容包括模块化设计、类型声明管理、代码分割、热更新原理以及构建性能调优。通过完整项目示例,帮助开发者提升代码可维护性与开发效率。

20

2026.02.13

Redis高可用架构与分布式缓存实战
Redis高可用架构与分布式缓存实战

本专题围绕 Redis 在高并发系统中的应用展开,系统讲解主从复制、哨兵机制、Cluster 集群模式及数据分片原理。内容涵盖缓存穿透与雪崩解决方案、分布式锁实现、热点数据优化及持久化策略。通过真实业务场景演示,帮助开发者构建高可用、可扩展的分布式缓存系统。

26

2026.02.13

c语言 数据类型
c语言 数据类型

本专题整合了c语言数据类型相关内容,阅读专题下面的文章了解更多详细内容。

29

2026.02.12

雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法
雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法

本专题系统整理雨课堂网页版官方入口及在线登录方式,涵盖账号登录流程、官方直连入口及平台访问方法说明,帮助师生用户快速进入雨课堂在线教学平台,实现便捷、高效的课程学习与教学管理体验。

14

2026.02.12

豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法
豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法

本专题汇总豆包AI官方网页版入口及在线使用方式,涵盖智能写作工具、图片生成体验入口和官网登录方法,帮助用户快速直达豆包AI平台,高效完成文本创作与AI生图任务,实现便捷智能创作体验。

524

2026.02.12

PostgreSQL性能优化与索引调优实战
PostgreSQL性能优化与索引调优实战

本专题面向后端开发与数据库工程师,深入讲解 PostgreSQL 查询优化原理与索引机制。内容包括执行计划分析、常见索引类型对比、慢查询优化策略、事务隔离级别以及高并发场景下的性能调优技巧。通过实战案例解析,帮助开发者提升数据库响应速度与系统稳定性。

53

2026.02.12

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
最新Python教程 从入门到精通
最新Python教程 从入门到精通

共4课时 | 22.4万人学习

Node.js 教程
Node.js 教程

共57课时 | 11.5万人学习

CSS3 教程
CSS3 教程

共18课时 | 5.7万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号