473,696 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with Firefox 2.0 behavior with this script

1 New Member
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(szDiv ID, iState) // 1 visible, 0 hidden
{
var obj = document.layers ? document.layers[szDivID] :
document.getEle mentById ? document.getEle mentById(szDivI D).style :
document.all[szDivID].style;
obj.visibility = document.layers ? (iState ? "show" : "hide") :
(iState ? "visible" : "hidden");
}
function doDelete(obj)
{
var deletePoint = document.getEle mentById(obj);
if (deletePoint.ha sChildNodes())
deletePoint.rem oveChild(delete Point.lastChild );

}

function deleteNode(obj)
{
var deleteSpot = document.getEle mentById(obj);
if (deleteSpot.has ChildNodes())
{
var toDelete = deleteSpot.last Child;
deleteSpot.remo veChild(toDelet e);
}
}

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

<div id="first" onClick="
if(lastfocus==n ull)
{
lastfocus=this. id;
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
}
else {
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
getElementById( lastfocus).styl e.zIndex=getEle mentById(this.i d).style.zIndex-1;
lastfocus=this. id ;
}
" style="backgrou nd-color:silver;wi dth:300;height: 100;left:100;po sition:absolute ; top:300;">
<a onClick=";toggl eBox('btnfirst' ,1);toggleBox(' first',0);">[x]</a>
FIRST LAYER
</div>

<div id="second" onClick="
if(lastfocus==n ull)
{
lastfocus=this. id;
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
}
else {
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
getElementById( lastfocus).styl e.zIndex=getEle mentById(this.i d).style.zIndex-1;
lastfocus=this. id ;
}
" style="backgrou nd-color:yellow;wi dth:300;height: 100;left:130;po sition:absolute ; top:220;">

<a onClick="toggle Box('btnsecond' ,1);toggleBox(' second',0);">[x]</a>
SECOND LAYER
</div>
<div id="third" onClick="
if(lastfocus==n ull)
{
lastfocus=this. id;
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
}
else {
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
getElementById( lastfocus).styl e.zIndex=getEle mentById(this.i d).style.zIndex-1;
lastfocus=this. id ;
}
" style="backgrou nd-color:skyblue;w idth:300;height :100;left:160;p osition:absolut e; top:250;">
<a onClick="toggle Box('btnthird', 1);toggleBox('t hird',0);">[x]</a>
THIRD LAYER
</div>

<div id="fourth" onClick="
if(lastfocus==n ull)
{
lastfocus=this. id;
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
}
else {
getElementById( this.id).style. zIndex=getEleme ntById(lastfocu s).style.zIndex +1;
getElementById( lastfocus).styl e.zIndex=getEle mentById(this.i d).style.zIndex-1;
lastfocus=this. id ;
}
" style="backgrou nd-color:green;wid th:300;height:1 00;left:190;pos ition:absolute; top:170;">
<a onClick="toggle Box('btnfourth' ,1);toggleBox(' fourth',0);">[x]</a>
FOURTH LAYER
</div>


<script type="text/javascript">
<!--
var theElement=docu ment.getElement ById('first');
-->
</script>

<!-- To Hide The DIV -->
<input style="visibili ty:hidden" id="btnfirst" type="button" onClick="toggle Box('btnfirst', 0);toggleBox('f irst',1)" value="First" />
<input style="visibili ty:hidden" id="btnsecond" type="button" onClick="toggle Box('btnsecond' ,0);toggleBox(' second',1)" value="Second" />
<input style="visibili ty:hidden" id="btnthird" type="button" onClick="toggle Box('btnthird', 0); toggleBox('thir d',1)" value="Third" />
<input style="visibili ty:hidden" id="btnfourth" type="button" onClick="toggle Box('btnfourth' ,0); toggleBox('four th',1)" value="Fourth" />


</HTML>

[/HTML]
Nov 23 '06 #1
2 4569
sreine
1 New Member
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 Recognized Expert Moderator MVP
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
2475
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, the script works well in Firefox, but IE throws error. (I have added the code snippet below). So, my question is: is there anyway to make the script work in all browser *without* any browser fix ie, without adding any browser detection check?...
3
10251
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 hidden rows take up page space even though their content is not visible. I have extracted the necessary code as shown below: ************************************************************************
10
19163
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 am passing to it. Everything works fine on IE 6. Here's a couple samples of what I am doing: // using GET url = 'http://www.myserver.com/cgi-bin/funct?key1=value1&key2=value2'
12
1882
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 "Retrieving results..." text. This should be really simple, but in IE, it does not work. Here's the code that is not executing in IE: And here is the context of that code, which is the AJAX function that is called when a radio button is clicked,...
1
2467
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 is to set the id and href of some objects dynamically during the onload of the page instead of hard-coding it in the HTML. I want to set the id/href so when I add new entries I don't have to remember to increment the id's. In FireFox, the href...
18
3335
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 the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I run the code on my local computer but I do have it when I run the code on geocities.
1
2443
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, several errors "variable is not defined" are displayed. What is more strange, the script is still working ! After each another refresh these errors are keep showing, only after I close site and open it again, these errors disappear, but only to next...
8
4168
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 following page load. When debugging through using Visual Studio, everything works fine. When using Firefox, everything works fine. However, when I view the site outside of the debugger in IE, it displays incorrect behavior. The Session variable...
7
4037
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. Before there are six characters entered in the CAPTCHA code field, the 'Send' button is supposed to be disabled. When there are at least six characters in the CAPTCHA code field, the script attempts to verify the CAPTCHA w/AJAX. If it verifies, it...
0
8656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9140
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9005
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8869
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7693
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3025
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2304
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.