Page 1 of 1

JavaScript problems

Posted: 2003-11-27 01:28am
by haas mark
I'm having some JavaScript problems. I have this code taken exactly as was written in the book that I'm using, but the File menu doesn't seem to want to work.. is there something I'm doing wrong or not seeing?

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Playing with pulldown menus</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">
<!--

stdBrowser = (document.getElementById) ? true : false

function toggleMenu(currElem,nextPos) {
  menuObj = (stdBrowser) ? document.getElementById(currElem).style : eval("document." + currElem)
  if (toggleMenu.arguments.length == 1) {
    nextPos = (parseInt(menuObj.top) == -5) ? -90 : -5
  }
  menuObj.top = (stdBrowser) ? nextPos + "px" : nextPos
}

-->
</script>
<style type="text/css">
<!--

.menu {position:absolute; font:12px arial, helvetica, sans-serif; background-color:#CCCCCC; layer-background-color:#CCCCCC; top:-90px}
#fileMenu {left:10px; width:70px}
#searchMenu {left:85px; width:100px}
A {text-decoration:none; color:#000000}
A:hover {background-color:#000000; color:#FFFFFF}

-->
</style>
</head>

<body bgcolor="#FFFFFF">

<div id="fileMenu" class="menu" onMousover="toggleMenu('fileMenu',-5)" onMouseout="toggleMenu('fileMenu',-90)"><br>
<a href="javascript:window.open()">Open</a><br>
<a href="javascript:window.print()">Print</a><br>
<a href="javascript:history.back()">Back</a>
<a href="javascript:history.forward()">Forward</a><br>
<a href="javascript:window.close()">Close</a><hr>
<a href="javascript:toggleMenu('fileMenu')">File</a>
</div>
<div id="searchMenu" class="menu" onMouseover="toggleMenu('searchMenu',-5)" onMouseout="toggleMenu9'searchMenu',-90)"><br>
<a href="http://www.ask.com">Ask Jeeves</a><br>
<a href="http://www.google.com">Google</a><br>
<a href="http://www.alltheweb.com">All The Web</a><br>
<a href="http://www.av.com">AltaVista</a><br>
<a href="http://www.dmoz.com">Open Directory</a><hr>
<a href="javascript:toggleMenu('searchMenu')">Search</a>
</div>

</body>
</html>
~ver

Posted: 2003-11-28 05:25am
by haas mark
-pokes- does anyone have any ideas? I need to know for my job, and my book isn't telling me anything...

~ver

Posted: 2003-11-28 06:54am
by BoredShirtless
onMouseover, not onMousover. And burn that book you took this shit from; anybody using the shorthand version of the if condition and concatenating strings at the same time should be shot. Actually, the shorthand if is used exclusively by blow hards too lazy to give a shit about the future readability of their crap. That's the problem with most developers; they think they're Gods gift to the world, and so don't have to spend the effort to make their code as readable as possible.

Posted: 2003-11-28 06:31pm
by haas mark
BoredShirtless wrote:onMouseover, not onMousover. And burn that book you took this shit from; anybody using the shorthand version of the if condition and concatenating strings at the same time should be shot. Actually, the shorthand if is used exclusively by blow hards too lazy to give a shit about the future readability of their crap. That's the problem with most developers; they think they're Gods gift to the world, and so don't have to spend the effort to make their code as readable as possible.
Hey, I fix my code up more than that... at least the CSS part. As for JavaScript, I hardly know anything about it.

Also, does anyone know if it's possible to have a list go backward in number?

~ver

Posted: 2003-11-28 06:44pm
by Pu-239
Also, what do you mean by list? Array? What do you mean go backward?

Best book on Javascript/HTML/CSS is http://www.oreilly.com/catalog/dhtmlref2/

Too bad it's 60$. Fortunately it happens to be in my library system. Check yours. All other books I've seen are crap. Best website is http://www.quirksmode.org/, which has almost everything the book has on Javascript and CSS (less on HTML, but then again you can look that up at w3c.org since most browsers support a good portion of HTML 4.0(1?)).

Posted: 2003-11-28 06:48pm
by haas mark
My JavaScript Book (except that it's 4th edition, not 5th).

I also have my HTML book from them. They are actually pretty good.

By lists, I mean like this:
  1. blah
  2. blah
  3. blah
By backwards, I mean going from 20-1 instead of 1-20.

Also, your second link doesn't work.

~ver

Posted: 2003-11-28 07:09pm
by Pu-239
Oh, I accidently put a . after the /

Fixed link is www.quirksmode.org