页面上未加载javascript
我在这里创建了一个非常简单的页面,并添加了一个使用javascript显示子菜单的菜单。我无法加载javascript,使用Firebug时也没有任何错误。除了javascript,我已经将我的页面剥离为几乎没有内容的页面,但它仍然无法加载。与菜单关联的CSS不会加载。我没有编写javascript,但对它的工作原理有一个基本概念 以下是网页:页面上未加载javascript,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我在这里创建了一个非常简单的页面,并添加了一个使用javascript显示子菜单的菜单。我无法加载javascript,使用Firebug时也没有任何错误。除了javascript,我已经将我的页面剥离为几乎没有内容的页面,但它仍然无法加载。与菜单关联的CSS不会加载。我没有编写javascript,但对它的工作原理有一个基本概念 以下是网页: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/h
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>The Journal</title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<link href="http://celt.miamioh.edu/ject/images/favicon.png" rel="shortcut icon">
<script src="http://celt.miamioh.edu/newject/menuscript.js" language="javascript" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="menustyle.css" media="screen, print" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<a href="Link 1" onmouseover="setOverImg('1','');overSub=true;showSubMenu('submenu1','button1');" onmouseout="setOutImg('1','');overSub=false;setTimeout('hideSubMenu(\'submenu1\')',delay);" target="http://celt.miamioh.edu/newject/about.php"><img src="buttons/button1up.png" border="0" id="button1" vspace="1" hspace="1"></a><a href="Link 2" onmouseover="setOverImg('2','');overSub=true;showSubMenu('submenu2','button2');" onmouseout="setOutImg('2','');overSub=false;setTimeout('hideSubMenu(\'submenu2\')',delay);" target="http://celt.miamioh.edu/newject/archive.php"><img src="buttons/button2up.png" border="0" id="button2" vspace="1" hspace="1"></a><a href="Link 3" onmouseover="setOverImg('3','');overSub=true;showSubMenu('submenu3','button3');" onmouseout="setOutImg('3','');overSub=false;setTimeout('hideSubMenu(\'submenu3\')',delay);" target="http://celt.miamioh.edu/journals/subscription/subscriptionpage.php"><img src="buttons/button3up.png" border="0" id="button3" vspace="1" hspace="1"></a><br>
</td></tr></table>
<p>Test page for javascript functionality.</p>
</body>
</html>
杂志
javascript功能的测试页面
下面是他:
subInfo[2] = new Array();
subInfo[3] = new Array();
//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo[1][1] = new Array("Overview","http://celt.miamioh.edu/newject/about.php","");
subInfo[1][2] = new Array("Free Sample Issue","http://celt.miamioh.edu/newject/issue.php?v=19&n=1","");
subInfo[1][3] = new Array("Editorial Board/Staff","http://celt.miamioh.edu/newject/staff.php","");
subInfo[1][4] = new Array("Manuscript Submission","http://celt.miamioh.edu/newject/submission.php","");
subInfo[2][1] = new Array("Current Issue","http://celt.miamioh.edu/newject/issue.php?v=25&n=2","");
subInfo[2][2] = new Array("Issue Archive","http://celt.miamioh.edu/newject/archive.php","");
subInfo[2][3] = new Array("Special Issue Archive","http://celt.miamioh.edu/newject/special.php","");
subInfo[2][4] = new Array("Search Archive","http://celt.miamioh.edu/newject/search.php","");
subInfo[3][1] = new Array("Journal Subscription","http://celt.miamioh.edu/journals/subscription/subscriptionpage.php","");
subInfo[3][2] = new Array("Order Back Issue","http://celt.miamioh.edu/newject/order_backissues.php","");
subInfo[3][3] = new Array("Order Individual Articles","http://celt.miamioh.edu/newject/order_articles.php","");
//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 9;
var ySubOffset = 34;
//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
totalButtons = upSources.length;
// GENERATE SUB MENUS
for ( x=0; x<totalButtons; x++) {
// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
if ( subInfo[x+1].length < 1 ) {
document.write('<div id="submenu' + (x+1) + '">');
// SET DIV FOR BUTTONS WITH SUBMENU
} else {
document.write('<div id="submenu' + (x+1) + '" class="dropmenu" ');
document.write('onMouseOver="overSub=true;');
document.write('setOverImg(\'' + (x+1) + '\',\'\');"');
document.write('onMouseOut="overSub=false;');
document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);');
document.write('setOutImg(\'' + (x+1) + '\',\'\');">');
document.write('<ul>');
for ( k=0; k<subInfo[x+1].length-1; k++ ) {
document.write('<li>');
document.write('<a href="' + subInfo[x+1][k+1][1] + '" ');
document.write('target="' + subInfo[x+1][k+1][2] + '">');
document.write( subInfo[x+1][k+1][0] + '</a>');
document.write('</li>');
}
document.write('</ul>');
}
document.write('</div>');
}
//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
for ( x=0; x<totalButtons; x++ ) {
buttonUp = new Image();
buttonUp.src = buttonFolder + upSources[x];
buttonOver = new Image();
buttonOver.src = buttonFolder + overSources[x];
}
}
// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}
// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}
//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null;
}
// GET X COORDINATE
function getRealLeft(id) {
var el = getElement(id);
if (el) {
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
}
// GET Y COORDINATE
function getRealTop(id) {
var el = getElement(id);
if (el) {
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
}
// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
var el = getElement(objectID);
el.style.left = x;
el.style.top = y;
}
// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
hideAllSubMenus();
butX = getRealLeft(buttonID);
butY = getRealTop(buttonID);
moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}
// HIDE ALL SUB MENUS
function hideAllSubMenus() {
for ( x=0; x<totalButtons; x++) {
moveObjectTo("submenu" + (x+1) + "",-500, -500 );
}
}
// HIDE ONE SUB MENU
function hideSubMenu(subID) {
if ( overSub == false ) {
moveObjectTo(subID,-500, -500);
}
}
//preload();
subInfo[2]=新数组();
subInfo[3]=新数组();
//***在此处设置子菜单文本链接和目标***//
子信息[1][1]=新数组(“概述”http://celt.miamioh.edu/newject/about.php","");
子信息[1][2]=新数组(“免费样本发布”http://celt.miamioh.edu/newject/issue.php?v=19&n=1","");
子信息[1][3]=新数组(“编辑委员会/工作人员”http://celt.miamioh.edu/newject/staff.php","");
子信息[1][4]=新数组(“提交稿件”http://celt.miamioh.edu/newject/submission.php","");
子信息[2][1]=新数组(“当前问题”http://celt.miamioh.edu/newject/issue.php?v=25&n=2","");
子信息[2][2]=新阵列(“发布存档”http://celt.miamioh.edu/newject/archive.php","");
子信息[2][3]=新数组(“特刊存档”http://celt.miamioh.edu/newject/special.php","");
子信息[2][4]=新数组(“搜索存档”http://celt.miamioh.edu/newject/search.php","");
子信息[3][1]=新数组(“日记订阅”http://celt.miamioh.edu/journals/subscription/subscriptionpage.php","");
子信息[3][2]=新数组(“订单回发”http://celt.miamioh.edu/newject/order_backissues.php","");
子信息[3][3]=新数组(“订购单个物品”http://celt.miamioh.edu/newject/order_articles.php","");
//***设置子菜单位置(相对于按钮)***//
var xSubOffset=9;
var ySubOffset=34;
//***在此点之外没有其他设置***//
var overSub=假;
无功延迟=1000;
totalButtons=upSources.length;
//生成子菜单
对于(x=0;x您的src链接不正确,要匹配js文件中的url,它应该是
http://celt.miamioh.edu/newject/menuscript.js
我创建了您的文件副本,可以验证javascript是否确实运行
我还注意到您在底部注释了代码//preload();
,也许这就是您希望执行的
如果仍然没有得到预期的结果,请尝试添加一个调试器;
语句并在Firebug中运行,代码应在添加该代码的行上中断。您的javascript中有错误。如果您输入“”在浏览器中,你会看到它没有加载,所以……在上面,如果你正在检修,你应该考虑把它与现代事件侦听器相结合。谢谢,但不是。我在另一个原因编辑URL。在我的源文件中,它们都是匹配的。仍然没有。当我尝试了你的代码时,JS缺少引用。对于buttonFolder、upSources和overSources。您是否在某个地方定义了它们?否则,它会加载并尝试执行主按钮函数,但由于不知道这些变量是什么,它会对主按钮函数感到不安。