我有一个基于JavaScript的页面菜单,其中菜单项是从数据库生成的。简单的菜单系统看起来像
function LoadMenus() {
window.fw_menu_1 = new Menu("root",165,17,"Verdana, Arial, Helvetica, sans-serif",11,"#ffffff","#000000","#597B7B","#FFF9DC","left","middle",4,0,1000,-5,7,true,true,true,5,true,true);
fw_menu_1.addMenuItem("Menu Item 1","location='#'");
fw_menu_1.addMenuItem("Menu Item 2","location='#'");
fw_menu_1.addMenuItem("Menu Item 3","location='#'");
fw_menu_1.addMenuItem("Menu Item 4","location='#'");
fw_menu_1.addMenuItem("Menu Item 5","location='#'");
fw_menu_1.addMenuItem("Menu Item 6","location='#'");
fw_menu_1.hideOnMouseOut=true;
}
首先,在我使用
之前,IE10上根本没有显示该菜单<meta http-equiv="X-UA-Compatible" content="IE=9">
但是当我能够显示菜单时,除了菜单项6之外,所有项目都有新的换行符,而我已经用不带空格的标签替换了常规空格。
为什么IE10会将所有常规空格切换到新的换行符?
由于
按要求
function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah)
{
this.version = "020320 [Menu; mm_menu.js]";
this.type = "Menu";
this.menuWidth = mw;
this.menuItemHeight = mh;
this.fontSize = fs;
this.fontWeight = "plain";
this.fontFamily = fnt;
this.fontColor = fclr;
this.fontColorHilite = fhclr;
this.bgColor = "#ffffff";
this.menuBorder = 1;
this.menuBgOpaque=opq;
this.menuItemBorder = 1;
this.menuItemIndent = idt;
this.menuItemBgColor = bg;
this.menuItemVAlign = valgn;
this.menuItemHAlign = halgn;
this.menuItemPadding = pad;
this.menuItemSpacing = space;
this.menuLiteBgColor = "#ffffff";
this.menuBorderBgColor = "#777777";
this.menuHiliteBgColor = bgh;
this.menuContainerBgColor = "#ffffff";
this.childMenuIcon = "arrows.gif";
this.submenuXOffset = sx;
this.submenuYOffset = sy;
this.submenuRelativeToItem = srel;
this.vertical = vert;
this.items = new Array();
this.actions = new Array();
this.childMenus = new Array();
this.hideOnMouseOut = true;
this.hideTimeout = to;
this.addMenuItem = addMenuItem;
this.writeMenus = writeMenus;
this.MM_showMenu = MM_showMenu;
this.onMenuItemOver = onMenuItemOver;
this.onMenuItemAction = onMenuItemAction;
this.hideMenu = hideMenu;
this.hideChildMenu = hideChildMenu;
if (!window.menus) window.menus = new Array();
this.label = " " + label;
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;
}
答案 0 :(得分:1)
您可能需要按照Microsoft的以下文档中的步骤操作:http://msdn.microsoft.com/en-us/hh779632.aspx。还可以尝试在modern.ie上通过扫描仪运行它:http://www.modern.ie/report#http%3A%2F%2Fuscib.org%20这可以检测常见问题。
例如,您正在使用X-UA兼容的元标记,该标记强制IE10以IE8模式呈现。将内容更改为值到边缘将告诉IE使用最新的可用模式
然后你没有doctype,所以它将以quirksmode呈现,而不是标准模式。由于脚本是旧的并且具有各种非标准代码,例如document.all,所以如果你把它放在标准模式下,它可能会在这个和它应该使用的正确代码之间绊倒。将HTML5文档类型添加到页面的顶部以尝试缓解这些问题:
答案 1 :(得分:0)
您在评论中提供的链接中缺少DOCTYPE。
http://www.w3.org/QA/2002/04/valid-dtd-list.html
试试这个:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
这在你的开始标记之前。