473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem with Firefox 2.0 behavior with this script

Can somebody please help me, i tried playing around with IE6 and Firefox 2.0 browser for setting zIndexes and hide & show of divs. It seems to work to both. I tried repeatedly clicking on different divs on IE and no problem, but on firefox if I do the same, some divs just got hidden without notice. try clicking variably on different divs and it will happen...

How do I make this stable?

-----------------------------
[HTML]
<HTML>
<HEAD>
<TITLE>LAYER TEST</TITLE>
<script type="text/javascript">
<!--
var lastfocus;


function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
var obj = document.layers ? document.layers[szDivID] :
document.getElementById ? document.getElementById(szDivID).style :
document.all[szDivID].style;
obj.visibility = document.layers ? (iState ? "show" : "hide") :
(iState ? "visible" : "hidden");
}
function doDelete(obj)
{
var deletePoint = document.getElementById(obj);
if (deletePoint.hasChildNodes())
deletePoint.removeChild(deletePoint.lastChild);

}

function deleteNode(obj)
{
var deleteSpot = document.getElementById(obj);
if (deleteSpot.hasChildNodes())
{
var toDelete = deleteSpot.lastChild;
deleteSpot.removeChild(toDelete);
}
}

// -->
</script>
</HEAD>
<BODY>

<div id="first" onClick="
if(lastfocus==null)
{
lastfocus=this.id;
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
}
else {
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
getElementById(lastfocus).style.zIndex=getElementB yId(this.id).style.zIndex-1;
lastfocus=this.id ;
}
" style="background-color:silver;width:300;height:100;left:100;positio n:absolute; top:300;">
<a onClick=";toggleBox('btnfirst',1);toggleBox('first ',0);">[x]</a>
FIRST LAYER
</div>

<div id="second" onClick="
if(lastfocus==null)
{
lastfocus=this.id;
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
}
else {
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
getElementById(lastfocus).style.zIndex=getElementB yId(this.id).style.zIndex-1;
lastfocus=this.id ;
}
" style="background-color:yellow;width:300;height:100;left:130;positio n:absolute; top:220;">

<a onClick="toggleBox('btnsecond',1);toggleBox('secon d',0);">[x]</a>
SECOND LAYER
</div>
<div id="third" onClick="
if(lastfocus==null)
{
lastfocus=this.id;
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
}
else {
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
getElementById(lastfocus).style.zIndex=getElementB yId(this.id).style.zIndex-1;
lastfocus=this.id ;
}
" style="background-color:skyblue;width:300;height:100;left:160;positi on:absolute; top:250;">
<a onClick="toggleBox('btnthird',1);toggleBox('third' ,0);">[x]</a>
THIRD LAYER
</div>

<div id="fourth" onClick="
if(lastfocus==null)
{
lastfocus=this.id;
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
}
else {
getElementById(this.id).style.zIndex=getElementByI d(lastfocus).style.zIndex+1;
getElementById(lastfocus).style.zIndex=getElementB yId(this.id).style.zIndex-1;
lastfocus=this.id ;
}
" style="background-color:green;width:300;height:100;left:190;position :absolute; top:170;">
<a onClick="toggleBox('btnfourth',1);toggleBox('fourt h',0);">[x]</a>
FOURTH LAYER
</div>


<script type="text/javascript">
<!--
var theElement=document.getElementById('first');
-->
</script>

<!-- To Hide The DIV -->
<input style="visibility:hidden" id="btnfirst" type="button" onClick="toggleBox('btnfirst',0);toggleBox('first' ,1)" value="First" />
<input style="visibility:hidden" id="btnsecond" type="button" onClick="toggleBox('btnsecond',0);toggleBox('secon d',1)" value="Second" />
<input style="visibility:hidden" id="btnthird" type="button" onClick="toggleBox('btnthird',0); toggleBox('third',1)" value="Third" />
<input style="visibility:hidden" id="btnfourth" type="button" onClick="toggleBox('btnfourth',0); toggleBox('fourth',1)" value="Fourth" />


</HTML>

[/HTML]
Nov 23 '06 #1
2 4542
sreine
1
Forgive me if this reply appears twice. There seemed to be an error when I hit submit the first time and I never saw the reply show up in the forum so and resending it.

I think I understand what is going wrong with your script as I am seeing the same thing with mine when I try to do getElementById().style.zIndex = getElementById().style.zIndex+1. I used firebug (great tool) to debug and the following is happening. If I happen to have a zindex of 14 and increment by 1, the result is 141, not 15. The addition being done is character based, not numeric. I have tried several workarounds, none solve the problem. I have researched the issue on the web (finally found this post) and the only other info I have found is a few people saying that the element on which the zindex is being referenced must have one of the position attributes set. Unfortunately, I already have position attributes set on all the div elements I am trying to operate on.

Maybe with this info, you can work a solution and share it with me,

thanks, Steve
Jan 30 '07 #2
acoder
16,027 Expert Mod 8TB
Hi Steve, welcome to The Scripts.

Try using parseInt on the zindex.
Jan 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: R. Rajesh Jeba Anbiah | last post by:
In IE, I could be able to directly refer the "id", but it isn't possible in Firefox. Somewhere I read the solution is to refer the id like document.getElementById("month") in Firefox. If I do so,...
3
by: shreddie | last post by:
Could anyone assist with the following problem? I'm using JavaScript to hide/show table rows depending on the option selected in radio buttons. The script works fine in IE but in Firefox the...
10
by: Danny | last post by:
Hi all, I am having some odd problems with AJAX on Firefox (1.5). When I use GET as the request method everything works ok, but when I do a POST the remote function doesn't get the parameters I...
12
by: Joel Byrd | last post by:
I am making an AJAX call when any one of a number of inputs in a form (search criteria) are clicked, checked, changed, etc. When the user clicks, checks, whatever, I am trying to display a...
1
by: KPS | last post by:
I'm attempting to create a simple treeview-like behavior in JavaScript. The desired behavior happens in IE but I cannot get the same to happen in FireFox. The primary thing I want to accomplish...
18
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to...
1
by: Larax | last post by:
Alright, so here's the problem. I define a global variable in my script and then add methods/properties to it. Everything works great, no error in Javascript Console. But when I refresh site,...
8
by: Chris Cap | last post by:
I am getting some strange behavior when using RaiseCallbackEvent. I have a form that implements ICallbackEventHandler. During the client callback, a session variable is set that is used on the...
7
by: mike57 | last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.