By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,567 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,567 IT Pros & Developers. It's quick & easy.

Copied Javascript not working

P: n/a
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.MO USEMOVE) ;
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>

Oct 6 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
VK

Jarry wrote:
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...

Oct 6 '06 #2

P: n/a
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...


Jarry wrote:
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.MO USEMOVE) ;
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>
Oct 7 '06 #3

P: n/a
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...


Jarry wrote:
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.MO USEMOVE) ;
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>
Oct 7 '06 #4

P: n/a
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 ...

Oct 7 '06 #5

P: n/a
JRS: In article <11**********************@i42g2000cwa.googlegroups .com>,
dated Fri, 6 Oct 2006 12:11:31 remote, seen in
news:comp.lang.javascript, Jarry <Ha***********@gmail.composted :
>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.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 7 '06 #6

P: n/a
VK

Jarry wrote:
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>

Oct 7 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.