当前位置: 编程技术>php
本页文章导读:
▪用PHP4访问Oracle815
在Windosws 2000 Server 上用PHP4访问Oracle815 系统环境: 1、操作系统:Windows 2000 Server 2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版 3、安装路径:D:ORACLE 安装配置PHP4: 第一步,解开php-4.0.3-Win32.........
▪PHP怎样调用MSSQL的存储过程
//执行存储过程 for($i=0;$i<$ses_basket_items;$i++) { $query="exec add_ddxx @p_account=\"$session_account\", @p_name=\"$name[$i]\", @p_num=\"$num[$i]\", @p_marketprice=\"$marketprice[$i]\", @p_memberprice=\"$memberprice[$i]\", @p_priceoftax=.........
▪BBS(php & mysql)完整版(五)
//下面为menu_comment.js function fwLoadMenus() { if (window.fw_menu_0) return; window.fw_menu_0 = new Menu("root",92,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff"); fw_menu_0.addMenuItem("Javasc.........
[1]用PHP4访问Oracle815
来源: 互联网 发布时间: 2013-11-30
在Windosws 2000 Server 上用PHP4访问Oracle815
系统环境:
1、操作系统:Windows 2000 Server
2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版
3、安装路径:D:ORACLE
安装配置PHP4:
第一步,解开php-4.0.3-Win32.zip压缩包,把它放在C:PHP下面。
第二步,把C:PHP下面的php.ini-optimized文件复制到C:WINNT目录下,并改名成php.ini。
修改php.ini文件:
extension_dir = c:php
extension=php_oci8.dll 去掉前面的“;”号
extension=php_oracle.dll 去掉前面的“;”号
[browscap] browscap = c:phpbrowscapbrowscap.ini 去掉browscap项前面的“;”号
第三步,把C:PHPphp4ts.dll复制到C:WINNTsystem32目录下。
第四步,启动IIS管理程序。
开始—设置—控制面板—管理工具—Internet服务管理器 在“默认Web站点”上点鼠标右键,选属性,
这时系统弹出“默认Web站点属性”窗口:
应用程序名输入c:phpphp.exe %s %s 点击配置:
点击添加:
第五步,在“默认Web站点属性”窗口上点取“ISAPI筛选器”标签,点击“添加”按钮,
在弹出的“筛选器属性”窗口的“筛选器名称”中输入“PHP”,
在“可执行文件”中输入“C:phpsapiphp4isapi.dll”,确定。
第六步,REGEDIT,启动注册表编辑器 找到:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW3SVCParametersScript Map。
新建一字符串:输入名称.php
第七步,回到命令行窗口,输入“net stop iisadmin”命令,终止IIS服务。
系统会问你是否要将相关的服务也停止,答是。
第八步,输入“net start w3svc”命令,重新启动IIS服务。
第九步,把c:phpextensions下的php_oci8.dll、php_oracle.dll两个文件拷贝到c:php下
1、写第一个连接Oracle的代码test.php
<?php
$handle = ora_plogon("test@ora815", "gdj") or die; /* 创建连接oracle的句柄*/
$cursor = ora_open($handle); /* 打开它并赋给一个游标 */
ora_commitoff($handle);
$query = "SELECT * FROM rate"; /* 定义一个查询 */
ora_parse($cursor, $query) or die; /* 把这个查询赋给游标 */
ora_exec($cursor); /* 运行游标,也即运行这个查询*/
echo "<HTML><PRE>n";
echo "$querynn";
$numcols = 0;
while(ora_fetch($cursor)) { /* 将 $cursor中存着查询结果 echo */
$numcols = ora_numcols($cursor);
for ($column=0; $column < $numcols; $column++) {
$data = trim(ora_getcolumn($cursor, $column));
if($data == "") $data = "NULL";
echo "$datat";
}
echo "n";
}
$numrows = ora_numrows($cursor);
echo "nROWS RETURNED: $numrowsn";
echo "</PRE></HTML>n";
ora_close($cursor);
?>
系统环境:
1、操作系统:Windows 2000 Server
2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版
3、安装路径:D:ORACLE
安装配置PHP4:
第一步,解开php-4.0.3-Win32.zip压缩包,把它放在C:PHP下面。
第二步,把C:PHP下面的php.ini-optimized文件复制到C:WINNT目录下,并改名成php.ini。
修改php.ini文件:
extension_dir = c:php
extension=php_oci8.dll 去掉前面的“;”号
extension=php_oracle.dll 去掉前面的“;”号
[browscap] browscap = c:phpbrowscapbrowscap.ini 去掉browscap项前面的“;”号
第三步,把C:PHPphp4ts.dll复制到C:WINNTsystem32目录下。
第四步,启动IIS管理程序。
开始—设置—控制面板—管理工具—Internet服务管理器 在“默认Web站点”上点鼠标右键,选属性,
这时系统弹出“默认Web站点属性”窗口:
应用程序名输入c:phpphp.exe %s %s 点击配置:
点击添加:
第五步,在“默认Web站点属性”窗口上点取“ISAPI筛选器”标签,点击“添加”按钮,
在弹出的“筛选器属性”窗口的“筛选器名称”中输入“PHP”,
在“可执行文件”中输入“C:phpsapiphp4isapi.dll”,确定。
第六步,REGEDIT,启动注册表编辑器 找到:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW3SVCParametersScript Map。
新建一字符串:输入名称.php
第七步,回到命令行窗口,输入“net stop iisadmin”命令,终止IIS服务。
系统会问你是否要将相关的服务也停止,答是。
第八步,输入“net start w3svc”命令,重新启动IIS服务。
第九步,把c:phpextensions下的php_oci8.dll、php_oracle.dll两个文件拷贝到c:php下
1、写第一个连接Oracle的代码test.php
<?php
$handle = ora_plogon("test@ora815", "gdj") or die; /* 创建连接oracle的句柄*/
$cursor = ora_open($handle); /* 打开它并赋给一个游标 */
ora_commitoff($handle);
$query = "SELECT * FROM rate"; /* 定义一个查询 */
ora_parse($cursor, $query) or die; /* 把这个查询赋给游标 */
ora_exec($cursor); /* 运行游标,也即运行这个查询*/
echo "<HTML><PRE>n";
echo "$querynn";
$numcols = 0;
while(ora_fetch($cursor)) { /* 将 $cursor中存着查询结果 echo */
$numcols = ora_numcols($cursor);
for ($column=0; $column < $numcols; $column++) {
$data = trim(ora_getcolumn($cursor, $column));
if($data == "") $data = "NULL";
echo "$datat";
}
echo "n";
}
$numrows = ora_numrows($cursor);
echo "nROWS RETURNED: $numrowsn";
echo "</PRE></HTML>n";
ora_close($cursor);
?>
[2]PHP怎样调用MSSQL的存储过程
来源: 互联网 发布时间: 2013-11-30
//执行存储过程
for($i=0;$i<$ses_basket_items;$i++)
{
$query="exec add_ddxx
@p_account=\"$session_account\",
@p_name=\"$name[$i]\",
@p_num=\"$num[$i]\",
@p_marketprice=\"$marketprice[$i]\",
@p_memberprice=\"$memberprice[$i]\",
@p_priceoftax=\"$notaxprice[$i]\",
@p_priceoflast=\"$lastprice[$i]\",
@p_sumprice=\"$price[$i]\",
@p_buy_date=\"$date\",
@p_flag=\"$p_flag\"";
$result=mssql_query($query,$connection) or die("存储过程执行错误,无法执行该SQL:$query");
}
for($i=0;$i<$ses_basket_items;$i++)
{
$query="exec add_ddxx
@p_account=\"$session_account\",
@p_name=\"$name[$i]\",
@p_num=\"$num[$i]\",
@p_marketprice=\"$marketprice[$i]\",
@p_memberprice=\"$memberprice[$i]\",
@p_priceoftax=\"$notaxprice[$i]\",
@p_priceoflast=\"$lastprice[$i]\",
@p_sumprice=\"$price[$i]\",
@p_buy_date=\"$date\",
@p_flag=\"$p_flag\"";
$result=mssql_query($query,$connection) or die("存储过程执行错误,无法执行该SQL:$query");
}
[3]BBS(php & mysql)完整版(五)
来源: 互联网 发布时间: 2013-11-30
//下面为menu_comment.js
function fwLoadMenus() {
if (window.fw_menu_0) return;
window.fw_menu_0 = new Menu("root",92,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_0.addMenuItem("Javascript","window.open('left.php', '_self');");
fw_menu_0.addMenuItem("Css快速入门","window.open('left.php', '_self');");
fw_menu_0.addMenuItem("JS在线资源","window.open('left.php', '_self');");
fw_menu_0.addMenuItem("相关论坛","window.open('php3.php?part=4&&p=1', '_self');");
fw_menu_0.fontWeight="solid";
fw_menu_0.hideOnMouseOut=true;
window.fw_menu_1 = new Menu("root",92,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_1.addMenuItem("Dreamwaver","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("Firework","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("Flash入门","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("Html教程","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("相关论坛","window.open('php3.php?part=3&&p=1', '_self');");
fw_menu_1.fontWeight="solid";
fw_menu_1.hideOnMouseOut=true;
window.fw_menu_2 = new Menu("root",86,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_2.addMenuItem("Mysql介绍","window.open('mysql1.php', '_self');");
fw_menu_2.addMenuItem("在线下载","window.open('mysql2.php', '_self');");
fw_menu_2.addMenuItem("学习教程","window.open('mysql4a.php', '_self');");
fw_menu_2.addMenuItem("Mysql论坛","window.open('php3.php?part=2&&p=1', '_self');");
fw_menu_2.fontWeight="solid";
fw_menu_2.hideOnMouseOut=true;
window.fw_menu_3 = new Menu("root",76,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_3.addMenuItem("安装配置","window.open('php1.php?id1=1&&id2=1', '_self');");
fw_menu_3.addMenuItem("程序代码","window.open('php2.php?id1=2&&id2=1', '_self');");
fw_menu_3.addMenuItem("学习教程","window.open('php4.php?id1=4&&id2=1', '_self');");
fw_menu_3.addMenuItem("PHP论坛","window.open('php3.php?part=1&&p=1', '_self');");
fw_menu_3.fontWeight="solid";
fw_menu_3.hideOnMouseOut=true;
fw_menu_3.writeMenus();
} // fwLoadMenus()
//下面是fw_menu.js
function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh) {
this.version = "990702 [Menu; menu.js]";
this.type = "Menu";
this.menuWidth = mw;
this.menuItemHeight = mh;
this.fontSize = fs||12;
this.fontWeight = "plain";
this.fontFamily = fnt||"arial,helvetica,verdana,sans-serif";
this.fontColor = fclr||"#000000";
this.fontColorHilite = fhclr||"#ffffff";
this.bgColor = "#555555";
this.menuBorder = 1;
this.menuItemBorder = 1;
this.menuItemBgColor = bg||"#cccccc";
this.menuLiteBgColor = "#ffffff";
this.menuBorderBgColor = "#777777";
this.menuHiliteBgColor = bgh||"#000084";
this.menuContainerBgColor = "#cccccc";
this.childMenuIcon = "arrows.gif";
this.items = new Array();
this.actions = new Array();
this.childMenus = new Array();
this.hideOnMouseOut = true;
this.addMenuItem = addMenuItem;
this.addMenuSeparator = addMenuSeparator;
this.writeMenus = writeMenus;
this.FW_showMenu = FW_showMenu;
this.onMenuItemOver = onMenuItemOver;
this.onMenuItemAction = onMenuItemAction;
this.hideMenu = hideMenu;
this.hideChildMenu = hideChildMenu;
if (!window.menus) window.menus = new Array();
this.label = label || "menuLabel" + window.menus.length;
window.menus[this.label] = this;
window.menus[window.menus.length] = this;
if (!window.activeMenus) window.activeMenus = new Array();
}
function addMenuItem(label, action) {
this.items[this.items.length] = label;
this.actions[this.actions.length] = action;
}
function addMenuSeparator() {
this.items[this.items.length] = "separator";
this.actions[this.actions.length] = "";
this.menuItemBorder = 0;
}
// For NS6.
function FIND(item) {
if (document.all) return(document.all[item]);
if (document.getElementById) return(document.getElementById(item));
return(false);
}
function writeMenus(container) {
if (window.triedToWriteMenus) return;
if (!container && document.layers) {
window.delayWriteMenus = this.writeMenus;
var timer = setTimeout('delayWriteMenus()', 250);
container = new Layer(100);
clearTimeout(timer);
} else if (document.all || document.hasChildNodes) {
document.writeln('<SPAN ID="menuContainer"></SPAN>');
container = FIND("menuContainer");
}
window.fwHideMenuTimer = null;
if (!container) return;
window.triedToWriteMenus = true;
container.isContainer = true;
container.menus = new Array();
for (var i=0; i<window.menus.length; i++)
container.menus[i] = window.menus[i];
window.menus.length = 0;
var countMenus = 0;
var countItems = 0;
var top = 0;
var content = '';
var lrs = false;
var theStat = "";
var tsc = 0;
if (document.layers) lrs = true;
for (var i=0; i<container.menus.length; i++, countMenus++) {
var menu = container.menus[i];
if (menu.bgImageUp) {
menu.menuBorder = 0;
menu.menuItemBorder = 0;
}
if (lrs) {
var menuLayer = new Layer(100, container);
var lite = new Layer(100, menuLayer);
lite.top = menu.menuBorder;
lite.left = menu.menuBorder;
var body = new Layer(100, lite);
body.top = menu.menuBorder;
body.left = menu.menuBorder;
} else {
content += ''+
'<DIV ID="menuLayer'+ countMenus +'" + (i * 100) +';visibility:hidden;">n'+
' <DIV ID="menuLite'+ countMenus +'" + menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;" onMouseOut="mouseoutMenu();">n'+
' <DIV ID="menuFg'+ countMenus +'" + menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;">n'+
'';
}
var x=i;
for (var i=0; i<menu.items.length; i++) {
var item = menu.items[i];
var childMenu = false;
var defaultHeight = menu.fontSize+6;
var defaultIndent = menu.fontSize;
if (item.label) {
item = item.label;
childMenu = true;
}
menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
menu.menuItemIndent = menu.menuItemIndent || defaultIndent;
var itemProps = 'font-family:' + menu.fontFamily +';font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + ';';
if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
if (document.all)
itemProps += 'font-size:' + menu.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onClick="onMenuItemAction(null,this);';
else if (!document.layers) {
itemProps += 'font-size:' + menu.fontSize + 'px;'; // zilla wants 12px.
}
var l;
if (lrs) {
l = new Layer(800,body);
}
var dTag = '<DIV ID="menuItem'+ countItems +'" + (i * menu.menuItemHeight) +';'+ itemProps +'">';
var dClose = '</DIV>'
if (menu.bgImageUp) {
menu.menuBorder = 0;
menu.menuItemBorder = 0;
dTag = '<DIV ID="menuItem'+ countItems +'" +menu.bgImageUp+');position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
if (document.layers) {
dTag = '<LAYER BACKGROUND="'+menu.bgImageUp+'" ID="menuItem'+ countItems +'" TOP="'+ (i * menu.menuItemHeight) +'" + itemProps +'">';
dClose = '</LAYER>';
}
}
var textProps = 'position:absolute;left:' + menu.menuItemIndent + ';top:1;';
if (lrs) {
textProps +=itemProps;
dTag = "";
dClose = "";
}
var dText = '<DIV ID="menuItemText'+ countItems +'" + textProps + 'color:'+ menu.fontColor +';">'+ item +' </DIV>n<DIV ID="menuItemHilite'+ countItems +'" + textProps + 'top:1;color:'+ menu.fontColorHilite +';visibility:hidden;">'+ item +' </DIV>';
if (item == "separator") {
content += ( dTag + '<DIV ID="menuSeparator'+ countItems +'" ></DIV>n<DIV ID="menuSeparatorLite'+ countItems +'" ></DIV>n' + dClose);
} else if (childMenu) {
content += ( dTag + dText + '<DIV ID="childMenu'+ countItems +'" ><IMG SRC="'+ menu.childMenuIcon +'"></DIV>n' + dClose);
} else {
content += ( dTag + dText + dClose);
}
if (lrs) {
l.document.open("text/html");
l.document.writeln(content);
l.document.close();
content = '';
theStat += "-";
tsc++;
if (tsc > 50) {
tsc = 0;
theStat = "";
}
status = theStat;
}
countItems++;
}
if (lrs) {
// focus layer
var focusItem = new Layer(100, body);
focusItem.visiblity="hidden";
focusItem.document.open("text/html");
focusItem.document.writeln(" ");
focusItem.document.close();
} else {
content += ' <DIV ID="focusItem'+ countMenus +'" onClick="onMenuItemAction(null,this);"> </DIV>n';
content += ' </DIV>n </DIV>n</DIV>n';
}
i=x;
}
if (document.layers) {
container.clip.width = window.innerWidth;
container.clip.height = window.innerHeight;
container.onmouseout = mouseoutMenu;
container.menuContainerBgColor = this.menuContainerBgColor;
for (var i=0; i<container.document.layers.length; i++) {
proto = container.menus[i];
var menu = container.document.layers[i];
container.menus[i].menuLayer = menu;
container.menus[i].menuLayer.Menu = container.menus[i];
container.menus[i].menuLayer.Menu.container = container;
var body = menu.document.layers[0].document.layers[0];
body.clip.width = proto.menuWidth || body.clip.width;
body.clip.height = proto.menuHeight || body.clip.height;
for (var n=0; n<body.document.layers.length-1; n++) {
var l = body.document.layers[n];
l.Menu = container.menus[i];
l.menuHiliteBgColor = proto.menuHiliteBgColor;
l.document.bgColor = proto.menuItemBgColor;
l.saveColor = proto.menuItemBgColor;
l.onmouseover = proto.onMenuItemOver;
l.onclick = proto.onMenuItemAction;
l.action = container.menus[i].actions[n];
l.focusItem = body.document.layers[body.document.layers.length-1];
l.clip.width = proto.menuWidth || body.clip.width + proto.menuItemIndent;
l.clip.height = proto.menuItemHeight || l.clip.height;
if (n>0) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder;
l.hilite = l.document.layers[1];
if (proto.bgImageUp) l.background.src = proto.bgImageUp;
l.document.layers[1].isHilite = true;
if (l.document.layers[0].id.indexOf("menuSeparator") != -1) {
l.hilite = null;
l.clip.height -= l.clip.height / 2;
l.document.layers[0].document.bgColor = proto.bgColor;
l.document.layers[0].clip.width = l.clip.width -2;
l.document.layers[0].clip.height = 1;
l.document.layers[1].document.bgColor = proto.menuLiteBgColor;
l.document.layers[1].clip.width = l.clip.width -2;
l.document.layers[1].clip.height = 1;
l.document.layers[1].top = l.document.layers[0].top + 1;
} else if (l.document.layers.length > 2) {
l.childMenu = container.menus[i].items[n].menuLayer;
l.document.layers[2].left = l.clip.width -13;
l.document.layers[2].top = (l.clip.height / 2) -4;
l.document.layers[2].clip.left += 3;
l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
}
}
body.document.bgColor = proto.bgColor;
body.clip.width = l.clip.width +proto.menuBorder;
body.clip.height = l.top + l.clip.height
function fwLoadMenus() {
if (window.fw_menu_0) return;
window.fw_menu_0 = new Menu("root",92,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_0.addMenuItem("Javascript","window.open('left.php', '_self');");
fw_menu_0.addMenuItem("Css快速入门","window.open('left.php', '_self');");
fw_menu_0.addMenuItem("JS在线资源","window.open('left.php', '_self');");
fw_menu_0.addMenuItem("相关论坛","window.open('php3.php?part=4&&p=1', '_self');");
fw_menu_0.fontWeight="solid";
fw_menu_0.hideOnMouseOut=true;
window.fw_menu_1 = new Menu("root",92,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_1.addMenuItem("Dreamwaver","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("Firework","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("Flash入门","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("Html教程","window.open('left.php', '_self');");
fw_menu_1.addMenuItem("相关论坛","window.open('php3.php?part=3&&p=1', '_self');");
fw_menu_1.fontWeight="solid";
fw_menu_1.hideOnMouseOut=true;
window.fw_menu_2 = new Menu("root",86,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_2.addMenuItem("Mysql介绍","window.open('mysql1.php', '_self');");
fw_menu_2.addMenuItem("在线下载","window.open('mysql2.php', '_self');");
fw_menu_2.addMenuItem("学习教程","window.open('mysql4a.php', '_self');");
fw_menu_2.addMenuItem("Mysql论坛","window.open('php3.php?part=2&&p=1', '_self');");
fw_menu_2.fontWeight="solid";
fw_menu_2.hideOnMouseOut=true;
window.fw_menu_3 = new Menu("root",76,20,"Verdana, Arial, Helvetica, sans-serif",12,"#6666ff","#ffffff","#FF9999","#6666ff");
fw_menu_3.addMenuItem("安装配置","window.open('php1.php?id1=1&&id2=1', '_self');");
fw_menu_3.addMenuItem("程序代码","window.open('php2.php?id1=2&&id2=1', '_self');");
fw_menu_3.addMenuItem("学习教程","window.open('php4.php?id1=4&&id2=1', '_self');");
fw_menu_3.addMenuItem("PHP论坛","window.open('php3.php?part=1&&p=1', '_self');");
fw_menu_3.fontWeight="solid";
fw_menu_3.hideOnMouseOut=true;
fw_menu_3.writeMenus();
} // fwLoadMenus()
//下面是fw_menu.js
function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh) {
this.version = "990702 [Menu; menu.js]";
this.type = "Menu";
this.menuWidth = mw;
this.menuItemHeight = mh;
this.fontSize = fs||12;
this.fontWeight = "plain";
this.fontFamily = fnt||"arial,helvetica,verdana,sans-serif";
this.fontColor = fclr||"#000000";
this.fontColorHilite = fhclr||"#ffffff";
this.bgColor = "#555555";
this.menuBorder = 1;
this.menuItemBorder = 1;
this.menuItemBgColor = bg||"#cccccc";
this.menuLiteBgColor = "#ffffff";
this.menuBorderBgColor = "#777777";
this.menuHiliteBgColor = bgh||"#000084";
this.menuContainerBgColor = "#cccccc";
this.childMenuIcon = "arrows.gif";
this.items = new Array();
this.actions = new Array();
this.childMenus = new Array();
this.hideOnMouseOut = true;
this.addMenuItem = addMenuItem;
this.addMenuSeparator = addMenuSeparator;
this.writeMenus = writeMenus;
this.FW_showMenu = FW_showMenu;
this.onMenuItemOver = onMenuItemOver;
this.onMenuItemAction = onMenuItemAction;
this.hideMenu = hideMenu;
this.hideChildMenu = hideChildMenu;
if (!window.menus) window.menus = new Array();
this.label = label || "menuLabel" + window.menus.length;
window.menus[this.label] = this;
window.menus[window.menus.length] = this;
if (!window.activeMenus) window.activeMenus = new Array();
}
function addMenuItem(label, action) {
this.items[this.items.length] = label;
this.actions[this.actions.length] = action;
}
function addMenuSeparator() {
this.items[this.items.length] = "separator";
this.actions[this.actions.length] = "";
this.menuItemBorder = 0;
}
// For NS6.
function FIND(item) {
if (document.all) return(document.all[item]);
if (document.getElementById) return(document.getElementById(item));
return(false);
}
function writeMenus(container) {
if (window.triedToWriteMenus) return;
if (!container && document.layers) {
window.delayWriteMenus = this.writeMenus;
var timer = setTimeout('delayWriteMenus()', 250);
container = new Layer(100);
clearTimeout(timer);
} else if (document.all || document.hasChildNodes) {
document.writeln('<SPAN ID="menuContainer"></SPAN>');
container = FIND("menuContainer");
}
window.fwHideMenuTimer = null;
if (!container) return;
window.triedToWriteMenus = true;
container.isContainer = true;
container.menus = new Array();
for (var i=0; i<window.menus.length; i++)
container.menus[i] = window.menus[i];
window.menus.length = 0;
var countMenus = 0;
var countItems = 0;
var top = 0;
var content = '';
var lrs = false;
var theStat = "";
var tsc = 0;
if (document.layers) lrs = true;
for (var i=0; i<container.menus.length; i++, countMenus++) {
var menu = container.menus[i];
if (menu.bgImageUp) {
menu.menuBorder = 0;
menu.menuItemBorder = 0;
}
if (lrs) {
var menuLayer = new Layer(100, container);
var lite = new Layer(100, menuLayer);
lite.top = menu.menuBorder;
lite.left = menu.menuBorder;
var body = new Layer(100, lite);
body.top = menu.menuBorder;
body.left = menu.menuBorder;
} else {
content += ''+
'<DIV ID="menuLayer'+ countMenus +'" + (i * 100) +';visibility:hidden;">n'+
' <DIV ID="menuLite'+ countMenus +'" + menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;" onMouseOut="mouseoutMenu();">n'+
' <DIV ID="menuFg'+ countMenus +'" + menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;">n'+
'';
}
var x=i;
for (var i=0; i<menu.items.length; i++) {
var item = menu.items[i];
var childMenu = false;
var defaultHeight = menu.fontSize+6;
var defaultIndent = menu.fontSize;
if (item.label) {
item = item.label;
childMenu = true;
}
menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
menu.menuItemIndent = menu.menuItemIndent || defaultIndent;
var itemProps = 'font-family:' + menu.fontFamily +';font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + ';';
if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
if (document.all)
itemProps += 'font-size:' + menu.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onClick="onMenuItemAction(null,this);';
else if (!document.layers) {
itemProps += 'font-size:' + menu.fontSize + 'px;'; // zilla wants 12px.
}
var l;
if (lrs) {
l = new Layer(800,body);
}
var dTag = '<DIV ID="menuItem'+ countItems +'" + (i * menu.menuItemHeight) +';'+ itemProps +'">';
var dClose = '</DIV>'
if (menu.bgImageUp) {
menu.menuBorder = 0;
menu.menuItemBorder = 0;
dTag = '<DIV ID="menuItem'+ countItems +'" +menu.bgImageUp+');position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
if (document.layers) {
dTag = '<LAYER BACKGROUND="'+menu.bgImageUp+'" ID="menuItem'+ countItems +'" TOP="'+ (i * menu.menuItemHeight) +'" + itemProps +'">';
dClose = '</LAYER>';
}
}
var textProps = 'position:absolute;left:' + menu.menuItemIndent + ';top:1;';
if (lrs) {
textProps +=itemProps;
dTag = "";
dClose = "";
}
var dText = '<DIV ID="menuItemText'+ countItems +'" + textProps + 'color:'+ menu.fontColor +';">'+ item +' </DIV>n<DIV ID="menuItemHilite'+ countItems +'" + textProps + 'top:1;color:'+ menu.fontColorHilite +';visibility:hidden;">'+ item +' </DIV>';
if (item == "separator") {
content += ( dTag + '<DIV ID="menuSeparator'+ countItems +'" ></DIV>n<DIV ID="menuSeparatorLite'+ countItems +'" ></DIV>n' + dClose);
} else if (childMenu) {
content += ( dTag + dText + '<DIV ID="childMenu'+ countItems +'" ><IMG SRC="'+ menu.childMenuIcon +'"></DIV>n' + dClose);
} else {
content += ( dTag + dText + dClose);
}
if (lrs) {
l.document.open("text/html");
l.document.writeln(content);
l.document.close();
content = '';
theStat += "-";
tsc++;
if (tsc > 50) {
tsc = 0;
theStat = "";
}
status = theStat;
}
countItems++;
}
if (lrs) {
// focus layer
var focusItem = new Layer(100, body);
focusItem.visiblity="hidden";
focusItem.document.open("text/html");
focusItem.document.writeln(" ");
focusItem.document.close();
} else {
content += ' <DIV ID="focusItem'+ countMenus +'" onClick="onMenuItemAction(null,this);"> </DIV>n';
content += ' </DIV>n </DIV>n</DIV>n';
}
i=x;
}
if (document.layers) {
container.clip.width = window.innerWidth;
container.clip.height = window.innerHeight;
container.onmouseout = mouseoutMenu;
container.menuContainerBgColor = this.menuContainerBgColor;
for (var i=0; i<container.document.layers.length; i++) {
proto = container.menus[i];
var menu = container.document.layers[i];
container.menus[i].menuLayer = menu;
container.menus[i].menuLayer.Menu = container.menus[i];
container.menus[i].menuLayer.Menu.container = container;
var body = menu.document.layers[0].document.layers[0];
body.clip.width = proto.menuWidth || body.clip.width;
body.clip.height = proto.menuHeight || body.clip.height;
for (var n=0; n<body.document.layers.length-1; n++) {
var l = body.document.layers[n];
l.Menu = container.menus[i];
l.menuHiliteBgColor = proto.menuHiliteBgColor;
l.document.bgColor = proto.menuItemBgColor;
l.saveColor = proto.menuItemBgColor;
l.onmouseover = proto.onMenuItemOver;
l.onclick = proto.onMenuItemAction;
l.action = container.menus[i].actions[n];
l.focusItem = body.document.layers[body.document.layers.length-1];
l.clip.width = proto.menuWidth || body.clip.width + proto.menuItemIndent;
l.clip.height = proto.menuItemHeight || l.clip.height;
if (n>0) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder;
l.hilite = l.document.layers[1];
if (proto.bgImageUp) l.background.src = proto.bgImageUp;
l.document.layers[1].isHilite = true;
if (l.document.layers[0].id.indexOf("menuSeparator") != -1) {
l.hilite = null;
l.clip.height -= l.clip.height / 2;
l.document.layers[0].document.bgColor = proto.bgColor;
l.document.layers[0].clip.width = l.clip.width -2;
l.document.layers[0].clip.height = 1;
l.document.layers[1].document.bgColor = proto.menuLiteBgColor;
l.document.layers[1].clip.width = l.clip.width -2;
l.document.layers[1].clip.height = 1;
l.document.layers[1].top = l.document.layers[0].top + 1;
} else if (l.document.layers.length > 2) {
l.childMenu = container.menus[i].items[n].menuLayer;
l.document.layers[2].left = l.clip.width -13;
l.document.layers[2].top = (l.clip.height / 2) -4;
l.document.layers[2].clip.left += 3;
l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
}
}
body.document.bgColor = proto.bgColor;
body.clip.width = l.clip.width +proto.menuBorder;
body.clip.height = l.top + l.clip.height
最新技术文章: