Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > HELP: Problem with Mozilla - Netscape and moving layers

Reply
Thread Tools

HELP: Problem with Mozilla - Netscape and moving layers

 
 
GD
Guest
Posts: n/a
 
      01-22-2005
I'm using a script that works great on IE, but not on mozilla. the
original one worked also on N4, but i'd like it to be funcional with
mozilla.

this is the orginal script:

*****************************
<Head>
<script language="JavaScript1.2">
var menu1top=230
var menuleft=-115


var pace=14

var step
var direction
var pause=25

var thismenu
var vorzeichen=1
var vorzeimenu1=-1


var menuismoving="no"


function inite() {
if (document.layers) {
document.menu1.left=menuleft
document.menu1.top=menu1top

}
if (document.all) {
document.all.menu1.style.posLeft=menuleft
document.all.menu1.style.posTop=menu1top
}
}

function getmenuname(clickedmenu) {
if (menuismoving=="no") {
if (document.layers) {
thismenu=eval("document."+clickedmenu)
}
if (document.all) {
thismenu=eval("document.all."+clickedmenu+".style" )
}
step=pace
checkdirection()
movemenu()
}
}

function checkdirection() {
if (document.layers) {
if
(thismenu==document.menu1){vorzeimenu1=vorzeimenu1 *-1;vorzeichen=vorzeimenu1}
}
if (document.all) {
if
(thismenu==document.all.menu1.style){vorzeimenu1=v orzeimenu1*-1;vorzeichen=vorzeimenu1}
}
menuismoving="yes"
}

function movemenu() {
if (document.layers) {
if (step>=0) {
thismenu.left+=step*vorzeichen
step--
var movetimer=setTimeout("movemenu()",pause)
}
else {
menuismoving="no"
clearTimeout(movetimer)
}
}
if (document.all) {
if (step>=0) {
thismenu.posLeft+=step*vorzeichen
step--
var movetimer=setTimeout("movemenu()",pause)
}
else {
menuismoving="no"
clearTimeout(movetimer)
}
}
}


</script>

<style type="text/css">
#menu1 {position:absolute;left:-1000px;}
.baseline {
position:absolute;
left:250px;
top:20px;
font-family:Arial;
font-size:9pt;
color:000000;
}
</STYLE>
</head>

<BODY bgcolor="#999999" onLoad="inite()">
<div align="center"> </div>


<DIV ID="menu1"><IMG SRC="webdesign.gif" USEMAP="#webdesign.gif"
WIDTH=150 HEIGHT=93 BORDER=0>
<MAP NAME="webdesign.gif">
<AREA SHAPE=RECT COORDS="117,0,150,93"
HREF="javascript:getmenuname('menu1')">
<AREA SHAPE=RECT COORDS="6,18,120,74" HREF="http://www.cnet.com">
</MAP></DIV>



</body>

<!--endo original script-->
*************************************

I modified it to try to make it work with mozilla, but it still
doesn't work. here is the modified script- thank you very much for
your help. GD


<Head>
<script language="JavaScript1.2">
var menu1top=230
var menuleft=-115


var pace=14

var step
var direction
var pause=25

var thismenu
var vorzeichen=1
var vorzeimenu1=-1


var menuismoving="no"


function inite() {
if (document.getElementById&&!document.all) {
document.getElementById("menu1").style.left=menule ft
document.getElementById("menu1").style.top=menu1to p

}
if (document.all) {
document.all.menu1.style.posLeft=menuleft
document.all.menu1.style.posTop=menu1top
}
}

function getmenuname(clickedmenu) {
if (menuismoving=="no") {
if (document.getElementById&&!document.all) {

thismenu=eval("document.getElementById('clickedmen u').style")
}
if (document.all) {
thismenu=eval("document.all."+clickedmenu+".style" )
}
step=pace
checkdirection()
movemenu()
}
}

function checkdirection() {
if (document.getElementById&&!document.all) {
if
(thismenu==document.getElementById("menu1").style) {vorzeimenu1=vorzeimenu1*-1;vorzeichen=vorzeimenu1}
}
if (document.all) {
if
(thismenu==document.all.menu1.style){vorzeimenu1=v orzeimenu1*-1;vorzeichen=vorzeimenu1}
}
menuismoving="yes"
}

function movemenu() {
if (document.getElementById&&!document.all) {
if (step>=0) {
thismenu.left+=step*vorzeichen
step--
var movetimer=setTimeout("movemenu()",pause)
}
else {
menuismoving="no"
clearTimeout(movetimer)
}
}
if (document.all) {
if (step>=0) {
thismenu.posLeft+=step*vorzeichen
step--
var movetimer=setTimeout("movemenu()",pause)
}
else {
menuismoving="no"
clearTimeout(movetimer)
}
}
}


</script>

<style type="text/css">
#menu1 {position:absolute;left:-1000px;}
.baseline {
position:absolute;
left:250px;
top:20px;
font-family:Arial;
font-size:9pt;
color:000000;
}
</STYLE>
</head>

<BODY bgcolor="#999999" onLoad="inite()">
<div align="center"> </div>


<DIV ID="menu1"><IMG SRC="webdesign.gif" USEMAP="#webdesign.gif"
WIDTH=150 HEIGHT=93 BORDER=0>
<MAP NAME="webdesign.gif">
<AREA SHAPE=RECT COORDS="117,0,150,93"
HREF="javascript:getmenuname('menu1')">
<AREA SHAPE=RECT COORDS="6,18,120,74" HREF="http://www.cnet.com">
</MAP></DIV>



</body>





 
Reply With Quote
 
 
 
 
Mark Preston
Guest
Posts: n/a
 
      01-22-2005
GD wrote:

> I'm using a script that works great on IE, but not on mozilla. the
> original one worked also on N4, but i'd like it to be funcional with
> mozilla.
>
> function inite() {
> if (document.layers) {
> document.menu1.left=menuleft
> document.menu1.top=menu1top
>

"Document.layers" is Netscape code up to version 4. Thereafter, it was
dropped and does not work.
> }
> if (document.all) {
> document.all.menu1.style.posLeft=menuleft
> document.all.menu1.style.posTop=menu1top
> }
> }
>

"Document.all" is Microsoft code and does not work (except on those,
such as Opera, which can mimic Microsoft-code).

The net effect you have is that you do not use *any* W3C-standard code
and therefore your script will not work withe modern browsers. Switch to
using the "document.getElementById("id_ref") methods.
 
Reply With Quote
 
 
 
 
GD
Guest
Posts: n/a
 
      01-24-2005
Thank you for your advise.

i've changed what you suggested, but somehow the last statement still
doesn't in Mozilla. in fact i got rid of most "if"and it works on IE,
but not Netscape.
Any idea why?

thanks,
GD


>GD wrote:
>
>> I'm using a script that works great on IE, but not on mozilla. the
>> original one worked also on N4, but i'd like it to be funcional with
>> mozilla.
>>
>> function inite() {
>> if (document.layers) {
>> document.menu1.left=menuleft
>> document.menu1.top=menu1top
>>

>"Document.layers" is Netscape code up to version 4. Thereafter, it was
>dropped and does not work.
>> }
>> if (document.all) {
>> document.all.menu1.style.posLeft=menuleft
>> document.all.menu1.style.posTop=menu1top
>> }
>> }
>>

>"Document.all" is Microsoft code and does not work (except on those,
>such as Opera, which can mimic Microsoft-code).
>
>The net effect you have is that you do not use *any* W3C-standard code
>and therefore your script will not work withe modern browsers. Switch to
>using the "document.getElementById("id_ref") methods.


 
Reply With Quote
 
Mark Preston
Guest
Posts: n/a
 
      01-24-2005
GD wrote:
> Thank you for your advise.
>
> i've changed what you suggested, but somehow the last statement still
> doesn't in Mozilla. in fact i got rid of most "if"and it works on IE,
> but not Netscape.
> Any idea why?
>

In place of *both* your "if" statements, you can use the following:-

if (document.getElementById()) {
document.getElementById(your_element_id).style...
etc.

This replaces all your "browser detection" with detecting the capability
of the browser rather than the manufacturer. Should it fail that test
(so, obviously, in an "else" clause) you can then run your browser
detection to deal with older browsers. There are more detailed examples
of this sort of thing in the group FAQ.
 
Reply With Quote
 
RobB
Guest
Posts: n/a
 
      01-25-2005
GD wrote:
> I'm using a script that works great on IE, but not on mozilla. the
> original one worked also on N4, but i'd like it to be funcional with
> mozilla.


(snip)

> I modified it to try to make it work with mozilla, but it still
> doesn't work. here is the modified script- thank you very much for
> your help. GD


(snip)

> thismenu=eval("document.getElementById('clickedmen u').style")


(snip)

Terrible script, with all that eval()ing...the above bit should
illustrate why. You're passing the string 'clickedmenu' to the
function, not the string contained in the variable clickedmenu.

thismenu=document.getElementById('clickedmenu').st yle

And:

thismenu=document.all[clickedmenu].style

There are so many menu scripts floating around these days, of every
variety, there's no reason to waste any time modifying relics of this
sort.

http://www.dyn-web.com/dhtml/slide/slide-out-menus.html

 
Reply With Quote
 
RobB
Guest
Posts: n/a
 
      01-25-2005
thismenu=document.getElementById(clickedmenu).styl e
Apologies (it's Monday here)...

 
Reply With Quote
 
GD
Guest
Posts: n/a
 
      01-25-2005
Thanks for your answer and the link, it's a great resource for scripts
and to learn DHTML.

somebody sent me the following script that works great. i'm unable to
add more than one tab though (i'm in the process of learning JS thru
other peoples scripts and website tutorials). what i like about it is
the use of image maps instead of styles for the menus for design
purposes. any help will be greatly appreciatted.

thanks, GD

***************************************

<HTML>
<HEAD>
<TITLE>Document Title</TITLE>

<script language="javascript">
<!--
var menu1top=230
var menuleft=-115
var step = 10
var pause=50
var dir=1

function init() {
document.getElementById("menu1").style.left=menule ft
document.getElementById("menu1").style.top=menu1to p
nowpos=menuleft
}


function movemenu() {
if(dir==1){nowpos+= step}
if(dir==0){nowpos-= step}

document.getElementById("menu1").style.left=nowpos
movetimer=setTimeout("movemenu()",pause)

if(nowpos>0-step){
clearTimeout(movetimer)
dir=0
}

if(nowpos<menuleft){
clearTimeout(movetimer)
dir=1
}

}

//-->
</script>

<style type="text/css">
#menu1 {position:absolute;}
..baseline {
position:absolute;
left:250px;
top:20px;
font-family:Arial;
font-size:9pt;
color:000000;
}
</STYLE>

</HEAD>

<BODY bgcolor="#999999" onload="init()">


<DIV ID="menu1"><IMG SRC="webdesign.gif" USEMAP="#webdesign.gif"
WIDTH=150 HEIGHT=93 BORDER=0>
<MAP NAME="webdesign.gif">
<AREA SHAPE=RECT COORDS="117,0,150,93" HREF="#null"
onclick="movemenu()">
<AREA SHAPE=RECT COORDS="6,18,120,74" HREF="http://www.cnet.com">
</MAP></DIV>

</BODY>
</HTML>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Moving Estimate, Local Movers, Long Distance Moving, PackingSupplies, Storage Rental, Home Moving, Apartment Moving, Office Moving,Commercial Moving linkswanted ASP .Net 0 01-06-2008 04:45 AM
Subnets between core and access/distribution layers & routing between layers J Cisco 0 12-13-2006 08:38 PM
Moving layers and control speed Fabri Javascript 4 02-08-2005 11:21 PM
Layers issue in Netscape 4.x - tabs question Jeannie Javascript 3 04-15-2004 03:18 PM
Netscape 4 layers problem mark rees Javascript 0 12-03-2003 04:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57