本文介绍了一个看似常见的JS菜单的问题......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使网页更加Netscape友好...< a

href =" http:www.gordonceilings.com">< / a>


我已经在离线暂存网站中更正了表格问题

(我在那里进行建设,然后在准备好后将其移至实际网站),

所以不要担心这些。我的问题在于左边的菜单。它显示了
,并且初始链接在Netscape 8中工作,但是菜单将不会下拉以显示子选择。我可以通过document.getElementById将子菜单下拉到

下拉菜单。争论,但其余的
菜单不会相应地向下移动以腾出空间,制造混乱的

混乱。它在IE5和6中完美无缺地使用document.all或

getElementById,但在寻找答案时,我看到IE更多

原谅...


这是脚本,它似乎是一个常见的脚本:


< SCRIPT LANGUAGE =" JavaScript">


//附加说明

//切换功能的输入变量是要打开/关闭的

子菜单的编号,

//从0开始,以及移动下面对象的像素数。

//例如切换(1,60)打开/关闭第二个子菜单并移动

低于60像素的对象。


var nom = 10; //菜单数

var usePictures = 0; //用图片? 1 =是,0 =否


var ttls = new Array(); //标题对象的数组

var subs = new Array(); //子菜单对象的数组

var lastn;

var lastmove;


if(document.layers){

visible =''show'';

hidden =''hide'';

}

else

if(document.all){

visible =''visible'';

hidden =''hidden'';

}

for(var i = 1; i< = nom; i ++){

ttls [i] =(''title''+ i );

subs [i] =(''submenu''+ i);

}

函数picopen(n){

title =(''title''+ n);

pic =(''pic''+ n);

if(document。图层){

document.layers [title] .document.images [pic] .src =" opened.gif";

}

else if(document.all){

document.all(pic).src =" opened.gif";

}

}

函数picclose(n){

title =(''title''+ n);

pic =(''pic' '+ n);

if(document.layers){

document.layers [title] .document.images [pic] .src =" closed.gif";

}

else if(document.all){

document.all(pic).src =" closed.gif";

}

}

lastn =(nom + 1);

lastmove = 0;

函数lasttoggle( n,移动){

if(n< = nom){

menu =(''submenu''+ n);

if(document.layers){

submenu = document.layers [menu];

}

else if(document.all){

子菜单= document.all(菜单).style;

}

if(submenu.visibility == visible){

submenu.visibility = hidden;

for(var i =(n + 1);我< = nom; i ++){

if(document.layers){

document.layers [ttls [i]]。top - = move;

document .layers [subs [i]]。top - = move;

}

else if(document.all){

document.all (ttls [i])。style.pixelTop - = move;

document.all(subs [i])。style.pixelTop - = move;

}

}

}

}

}

函数切换(n,move){

menu =(''submenu''+ n);

if(document.layers){

submenu = document.layers [menu ];

}

else if(document.all){

submenu = document.all(menu).style;

}

if(submenu.visibility == visible){

submenu.visibility = hidden;

if(usePictures)picclose (n);

for(var i =(n + 1); i< = nom; i ++){

if(document.layers){

document.layers [ttls [i]]。top - = move;

document.layers [subs [i]]。top - = move;

}

else if(document.all){

document.all(ttls [i])。style.pixelTop - = move;

document.all(subs [i])。style.pixelTop - = move;

}

}

}

else {

submenu.visibility = visible;

if(usePictures)picopen(n);

if(lastn!= n){

lasttoggle(lastn,lastmove);

}

for(var i =(n + 1);我< = nom; i ++){

if(document.layers){

document.layers [ttls [i]]。top + = move;

document .layers [subs [i]]。top + = move;

}

if(document.all){

document.all( ttls [i])。style.pixelTop + = move;

document.all(subs [i])。style.pixelTop + = move;

}

}

}

lastn = n;

lastmove = move;

}

函数loadFrames(frame1,page1){

eval(" parent。" + frame1 +" .location =''" + page1 +"''" ;);

}

//结束 - >


< / script>


到目前为止,我能找到关于这个脚本的人是那些有b
问题的人...也许是时候换一个新剧本了,但我真的很喜欢/>
不想重建菜单......

I am attempting to make a web page more Netscape friendly... <a
href="http:www.gordonceilings.com"></a>

I have already corrected the table issues in an offline staging site
(where I do the building and then move it to the live site when ready),
so don''t worry about those. My problem lies in the menu on the left. It
shows up and the initial links work in Netscape 8, but the menu will
not drop down to show the sub-selections. I can get the sub-menus to
drop down with "document.getElementById" arguments, but the rest of the
menu won''t move down accordingly to make room, making for a jumbled
mess. It works flawlessly in IE5 and 6 with either document.all or
getElementById, but in looking for an answer I see that IE is more
forgiving...

Here is the script, it seems to be a common one:

<SCRIPT LANGUAGE="JavaScript">

// ADDITIONAL NOTES
// The input variables to the toggle function are the number of the
submenu to open/close,
// starting with 0, and the number of pixels to move the objects below.
// For example toggle(1,60) opens/closes the second submenu and moves
the objects below 60 pixels.

var nom = 10; // Number of menus
var usePictures = 0; // use pictures? 1 = yes, 0 = no

var ttls = new Array(); // An array for the title objects
var subs = new Array(); // An array for the submenu objects
var lastn;
var lastmove;

if (document.layers) {
visible = ''show'';
hidden = ''hide'';
}
else
if (document.all) {
visible = ''visible'';
hidden = ''hidden'';
}
for (var i = 1; i <= nom; i++) {
ttls[i] = (''title'' + i);
subs[i] = (''submenu'' +i);
}
function picopen(n) {
title = (''title'' + n);
pic = (''pic'' + n);
if (document.layers) {
document.layers[title].document.images[pic].src = "opened.gif";
}
else if (document.all) {
document.all(pic).src = "opened.gif";
}
}
function picclose(n) {
title = (''title'' + n);
pic = (''pic'' + n);
if (document.layers) {
document.layers[title].document.images[pic].src = "closed.gif";
}
else if (document.all) {
document.all(pic).src = "closed.gif";
}
}
lastn = (nom + 1);
lastmove = 0;
function lasttoggle(n,move) {
if (n <= nom) {
menu = (''submenu'' + n);
if (document.layers) {
submenu = document.layers[menu];
}
else if (document.all) {
submenu = document.all(menu).style;
}
if (submenu.visibility == visible) {
submenu.visibility = hidden;
for (var i = (n+1); i <= nom; i++) {
if (document.layers) {
document.layers[ttls[i]].top -= move;
document.layers[subs[i]].top -= move;
}
else if (document.all) {
document.all(ttls[i]).style.pixelTop -= move;
document.all(subs[i]).style.pixelTop -= move;
}
}
}
}
}
function toggle(n,move) {
menu = (''submenu'' + n);
if (document.layers) {
submenu = document.layers[menu];
}
else if (document.all) {
submenu = document.all(menu).style;
}
if (submenu.visibility == visible) {
submenu.visibility = hidden;
if (usePictures) picclose(n);
for (var i = (n+1); i <= nom; i++) {
if (document.layers) {
document.layers[ttls[i]].top -= move;
document.layers[subs[i]].top -= move;
}
else if (document.all) {
document.all(ttls[i]).style.pixelTop -= move;
document.all(subs[i]).style.pixelTop -= move;
}
}
}
else {
submenu.visibility = visible;
if (usePictures) picopen(n);
if (lastn != n) {
lasttoggle(lastn,lastmove);
}
for (var i = (n+1); i <= nom; i++) {
if (document.layers) {
document.layers[ttls[i]].top += move;
document.layers[subs[i]].top += move;
}
if (document.all) {
document.all(ttls[i]).style.pixelTop += move;
document.all(subs[i]).style.pixelTop += move;
}
}
}
lastn = n;
lastmove = move;
}
function loadFrames(frame1,page1) {
eval("parent."+frame1+".location=''"+page1+"''");
}
// End -->

</script>

So far all I can find concerning this script is people that are having
problems with it... maybe it''s time for a new script, but I really
don''t want to have to rebuild the menu...

推荐答案





很多文件。图层(仅限NS4.x)和许多document.all(IE4仅[1]),

但不是很多W3C DOM。几年前是一个新脚本的时候了。


[1]其他浏览器确实支持它,虽然我似乎记得只有IE

才返回true如果你测试它,其他浏览器会认为如果你足够聪明地测试支持,那么你就足够聪明地使用W3C

DOM。


-

David Dorward< http://blog.dorward.me.uk/> < http://dorward.me.uk/>

首页是〜/ .bashrc的位置



Lots of document.layers (NS4.x only) and lots of document.all (IE4 only[1]),
but not a lot of W3C DOM. It was time for a new script several years ago.

[1] Other browsers do support it, although I seem to recall that only IE
returns true if you test for it, other browsers assume that if you are
smart enough to test for support, then you are smart enough to use the W3C
DOM.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is



这篇关于一个看似常见的JS菜单的问题......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 03:08