为何menu.htm 的扩展名该为.jsp时为何出现编译错误

javastart 2004-01-30 03:05:46
环境为win2000+jbuilder 9.0
我在做菜单时,menu.htm文件在IE中执行正确,但menu.htm 的扩展名该为.jsp为何menu.htm 的扩展名该为.jsp时为何出现编译错误


文件:menu.htm
<%@ page contentType="text/html; charset=GB2312"%>
<html>
<head>
<title></title>
</head>
<BODY bgColor=#ffffff id=bbody leftMargin=0
style="OVERFLOW: scroll; OVERFLOW-X: hidden; WIDTH: 100%" marginwidth="0">
<SCRIPT language=JavaScript src="m.js"></SCRIPT>

<SCRIPT language=JavaScript>
menu = new Menu();
menu.addItem("webmasterid", "aaa", "软件下载", null, null);
menu.addItem("newsid", "新闻站点", "新闻站点", null, null);
menu.addSubItem("webmasterid", "444444", "444444", "http://localhost:8080/jsp4.jsp");
menu.addSubItem("webmasterid", "cc", "cc", "http://localhost:8080/jsp4.jsp");
menu.addSubItem("webmasterid", "aa", "bb", null);
menu.addSubItem("newsid", "软件屋", "软件屋", "http://www.softhouse.com.cn/");
menu.showMenu();
</SCRIPT>

<SCRIPT language=JavaScript>
function UpdatePosition(){
// if (document.all) MainTable.style.top = bbody.scrollTop;
}
setInterval("UpdatePosition()", 100);
</SCRIPT>
</BODY></html>

文件menu.js
if (document.all) {n=0;ie=1;fShow="visible";fHide="hidden";}
if (document.layers) {n=1;ie=0;fShow="show"; fHide="hide";}

////////////////////////////////////////////////////////////////////////////
// Function Menu() //
// //
////////////////////////////////////////////////////////////////////////////
function Menu()
{
this.bgColor = "#D6D6CE";
this.menuFont = "宋体";
this.fontColor = "#001873";
this.addItem = addItem;
this.addSubItem = addSubItem;
this.showMenu = showMenu;
this.mainPaneBorder = 0;
this.subMenuPaneBorder = 0;
this.subMenuPaneWidth = 200;
lastMenu = null;

HTMLstr = "";
HTMLstr += "<!-- MENU PANE DECLARATION BEGINS -->\n";
HTMLstr += "\n";
HTMLstr += "<span id='MainTable' style='position:absolute;'>\n";
HTMLstr += "<table width='100%' bgcolor='"+this.bgColor+"' border='0'>\n";
HTMLstr += "<tr><td>\n";
HTMLstr += "\n";
HTMLstr += "<table bgcolor='"+this.bgColor+"'>\n";
HTMLstr += "<tr>\n";
HTMLstr += "<!-- MAIN MENU STARTS -->\n";
HTMLstr += "<!-- MAIN_MENU -->\n";
HTMLstr += "</tr>\n";
HTMLstr += "</table>\n";
HTMLstr += "\n";
HTMLstr += "<!-- MAIN MENU ENDS -->\n";
HTMLstr += "</td></tr>\n";
HTMLstr += "</table>\n";
HTMLstr += "\n";
HTMLstr += "<!-- SUB MENU STARTS -->\n";
HTMLstr += "<!-- SUB_MENU -->\n";
HTMLstr += "<!-- SUB MENU ENDS -->\n";
HTMLstr += "</span>\n";
HTMLstr += "\n";
HTMLstr += "<!-- MENU PANE DECALARATION ENDS -->\n";

}

function addItem(idItem, text, hint, location, altLocation)
{
var Lookup = "<!-- ITEM "+idItem+" -->";
if (HTMLstr.indexOf(Lookup) != -1)
{
alert(idParent + " already exist");
return;
}
var MENUitem = "";
MENUitem += "\n<!-- ITEM "+idItem+" -->\n";
MENUitem += "<td>\n";
MENUitem += "<div id='"+idItem+"' style='position:relative; font: "+this.menuFont+";'>\n";
MENUitem += "<a ";
MENUitem += "style='text-decoration: none; font: "+this.menuFont+"; color: "+this.fontColor+"; cursor: hand;' ";
if (hint != null)
MENUitem += "title='"+hint+"' ";
if (location != null)
{
MENUitem += "href='"+location+"' ";
MENUitem += "onmouseover=\"hideAll()\" ";
}
else
{
if (altLocation != null)
MENUitem += "href='"+altLocation+"' ";
else
MENUitem += "href='.' ";
MENUitem += "onmouseover=\"displaySubMenu('"+idItem+"')\" ";
MENUitem += "onclick=\"return false;\" "
}
MENUitem += ">";
MENUitem += "<span> |<span>\n";
MENUitem += text;
MENUitem += "</a>\n";
MENUitem += "</div>\n";
MENUitem += "</td>\n";
MENUitem += "<!-- END OF ITEM "+idItem+" -->\n\n";
MENUitem += "<!-- MAIN_MENU -->\n";

HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);
}

function addSubItem(idParent, text, hint, location)
{
var MENUitem = "";
Lookup = "<!-- ITEM "+idParent+" -->";
if (HTMLstr.indexOf(Lookup) == -1)
{
alert(idParent + " not found");
return;
}
Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
if (HTMLstr.indexOf(Lookup) == -1)
{
MENUitem += "\n";
MENUitem += "<div id='"+idParent+"submenu' style='position:absolute; visibility: hidden; width: "+this.subMenuPaneWidth+"; font: "+this.menuFont+"; color: "+this.fontColor+";'>\n";
MENUitem += "<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColor+"' width="+this.subMenuPaneWidth+">\n";
MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
MENUitem += "</table>\n";
MENUitem += "</div>\n";
MENUitem += "\n";
MENUitem += "<!-- SUB_MENU -->\n";
HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
}

Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
MENUitem = "<tr><td><a style='text-decoration: none; font: "+this.menuFont+"; color: blue;' title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";
MENUitem += Lookup;
HTMLstr = HTMLstr.replace(Lookup, MENUitem);
}

function showMenu()
{
document.writeln(HTMLstr);
}

////////////////////////////////////////////////////////////////////////////
// Private declaration
function displaySubMenu(idMainMenu)
{
var menu;
var submenu;

if (n)
{
menu = eval("document."+idMainMenu);
submenu = eval("document."+idMainMenu+"submenu");
if (lastMenu != null && lastMenu != submenu) hideAll();
submenu.left = menu.pageX;
submenu.top = menu.pageY + 20;
submenu.visibility = fShow;
} else if (ie) {
menu = eval(idMainMenu);
submenu = eval(idMainMenu+"submenu.style");
if (lastMenu != null && lastMenu != submenu) hideAll();
submenu.left = calculateSumOffset(menu, 'offsetLeft');
// submenu.top = calculateSumOffset(menu, 'offsetTop') + 25;
submenu.top = menu.style.top+30;
submenu.visibility = fShow;
}
lastMenu = submenu;
}

function hideAll()
{
if (lastMenu != null) {lastMenu.visibility = fHide;lastMenu.left = 0;}
lastMenu = null;
}

function calculateSumOffset(idItem, offsetName)
{
var totalOffset = 0;
var item = eval('idItem');
do
{
totalOffset += eval('item.'+offsetName);
item = eval('item.offsetParent');
} while (item != null);
return totalOffset;
}

document.body.onclick=hideAll;

...全文
51 1 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
thefishwilldie 2004-01-30
<SCRIPT language=JavaScript src="m.js"></SCRIPT>?
<SCRIPT language=JavaScript src="menu.js"></SCRIPT>吧
  • 打赏
  • 举报
回复
相关推荐
发帖
Web 开发
加入

8.0w+

社区成员

Java Web 开发
社区管理员
  • Web 开发社区
申请成为版主
帖子事件
创建了帖子
2004-01-30 03:05
社区公告
暂无公告