Copied Javascript not working

J

Jarry

I'm very new to javascipt, and I was copying this text out a book, but
it doesn't seem to be working. Any ideas (its probably a syntax error)?
Thank anyway!


<SCRIPT TYPE = "text/javascript">
<!--
if(document.layers)document.captureEvents(Event.MOUSEMOVE) ;
document.onmousemove = track;
divref = (document.all) ? "" : "document.";
stlref = (document.all) ? "style." : "";

function track(e) {

var x = (document.all) ? event.x : e.pageX;
var y = (document.all) ? event.y : e.pageY;
If( x<1 || x>65 || y<53 || y>123 )
eval( divref + "b." + stlref + "visibility = 'hidden'")
If( x<80 || x>145 || y<53 || y>123 )
eval( divref + "c." + stlref + "visibility = 'hidden'")
If( x<160 || x>225 || y<53 || y>123 )
eval( divref + "d." + stlref + "visibility = 'hidden'")
}

function reveal(menu){
eval( divref + menu + "." + stlref + "visibility = 'visible'" ); }
//-->
</SCRIPT>
<STYLE TYPE = "text/css">
<!--
..bar{ position:absolute; left:0; top:50; color:black; width:800;
height:20px; background:silver; font-family:verdana; font-size:10pt;
border-color:white; border-width:1; }
..menu { position:absolute; width:65; height:50; background:silver;
top:71px; visibility:hidden; font-family:verdana; font-size:10pt;
border-color:white; border-width:1px; }
//-->
</STYLE>
<DIV ID= "a" CLASS= "bar">
<A HREF = "javascript://" ONMOUSEOVER="reveal('b')">&nbsp;Menu 1</A> |
<A HREF = "javascript://" ONMOUSEOVER="reveal('c')">&nbsp;Menu 2</A> |
<A HREF = "javascript://" ONMOUSEOVER="reveal('d')">&nbsp;Menu 3</A> |
</DIV>

<DIV ID = "b" CLASS= "menu" STYLE= "left:0" LEFT= "0">
<A HREF "target1.html"> Item 1 </A>
<A HREF "target2.html"> Item 2 </A>
<A HREF "target3.html"> Item 3 </A> </DIV>

<DIV ID = "b" CLASS= "menu" STYLE= "left:0" LEFT= "0">
<A HREF "target4.html"> Item 1 </A>
<A HREF "target5.html"> Item 2 </A>
<A HREF "target6.html"> Item 3 </A> </DIV>

<DIV ID = "b" CLASS= "menu" STYLE= "left:0" LEFT= "0">
<A HREF "target7.html"> Item 1 </A>
<A HREF "target8.html"> Item 2 </A>
<A HREF "target9.html"> Item 3 </A> </DIV>
 
V

VK

Jarry said:
I'm very new to javascipt, and I was copying this text out a book

A Browser Wars' book... Sorry, man (Sir, sorry) but the world became
rather different ever since.

I'm personally in a gloomy mood now, but if you change document.all
into document.getElementById everywhere (and report your problems here
if any left) there are so many people ready to help you...
 
A

agapeton

Holy cow... that's OLD code. WOW!

First off... change all document.all to document.getElementById(put id
here)

Secondly, tell us what you want to do...
 
A

agapeton

Holy cow... that's OLD code. WOW!

First off... change all document.all to document.getElementById(put id
here)

Secondly, tell us what you want to do...
 
J

Jarry

What do you mean by "Put ID here", I just changed the document.all s to
document.getElementById s - I'm trying to create a dynamic drop down
menu, but if this codes too old, I might as well just go and get some
more ...
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Fri, 6 Oct 2006 12:11:31 remote, seen in
news:comp.lang.javascript said:
I'm very new to javascipt, and I was copying this text out a book, but
it doesn't seem to be working. Any ideas (its probably a syntax error)?

Choose a better book.

How should we know what you expect the code to do, when we can only see
what it does; you've not even told us which book it is, nor which
browser you are using.

First error - either you or the compositor is an insufficiently careful
copier :
If != if

It's a good idea to read the newsgroup and its FAQ. See below.
 
V

VK

Jarry said:
What do you mean by "Put ID here", I just changed the document.all s to
document.getElementById

document.all is an Internet Explorer's proprietary collection, that is
why anyone is suggesting to use the standard document.getElementById()
method instead (supported by InternetExplorer as well).
I'm trying to create a dynamic drop down
menu, but if this codes too old, I might as well just go and get some
more ...

That maybe the best idea - rather than refactoring from the scratch
this ancient script. Even if you want to create a dropdown for learning
purposes, it could be a much better sample found for comparison.

See for example <http://www.dynamicdrive.com/dynamicindex1/indexb.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top