473,573 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mozilla & IE object model differences?

The following code works fine on Mozilla but generates an error* on IE,
when the button calling the function is pressed and the slideshow is
either on the first slide or last slide. * I can't remember the exact
error and I'm on Linux/Mozilla at the moment, but I think it had a problem
with the object model?!?

The slideshow has a stack of div tags and the buttons are used to change
the z-order. Each div contains two other divs: one with a picture and one
with a description.

All this is generated on the fly in php, from a mySQL database, hence the
DOM parsing to find the appropriate div to bring to the front.

Thanks,

Greg

=============== =======

//The code that calls this function is an image in a table: <img
id='ex2-stepForward' name='stepForwa rd'
src='./images/site/stepForward.gif '
width='24'
height='24'
border='0'
onmouseover="ch angeImages(this .id, './images/site/stepForward-over.gif');
return true; "
onmouseout="cha ngeImages(this. id, './images/site/stepForward.gif ');
return true; "
onmousedown="ch angeImages(this .id, './images/site/stepForward-down.gif');
return true; "
onmouseup="chan geImages(this.i d, './images/site/stepForward-over.gif');
stepOne(event, this, 'forward'); return true; ">

=============== =============

//Steps back and forward in the stack of image/description containers
//for the group associated with the control pressed function stepOne(evt,
thisExercise, direction){
var nodeStep = thisExercise;
//parse UP the tree by parent
while (nodeStep.class Name != 'maskGroup'){
nodeStep = nodeStep.parent Node;
}
//parse DOWN the tree by sibling
while (nodeStep.class Name != 'picDescPair'){
nodeStep = nodeStep.nextSi bling;
}
//this is the first PicDescPair node
var firstPicDescPai rNode = nodeStep;
//this is the last sibling (We'll parse from firstPicDescPai rNode to the
last sibling looking for other PicDescPairs) var lastSiblingNode =
firstPicDescPai rNode.parentNod e.lastChild; //use an array to store all
the PicDescPairs found var arrayIdx = 0;
var picDescPairArra y = new Array(0);
//store the ID of the first one
picDescPairArra y[arrayIdx] = firstPicDescPai rNode.id; arrayIdx ++;
// loop until the last sibling, looking for more. A DO/WHILE loop might
be preferable? Check limiting case of single nodeStep while (nodeStep !=
lastSiblingNode ){
nodeStep = nodeStep.nextSi bling;
if ((nodeStep.clas sName == 'picDescPair') && (nodeStep.nodeN ame ==
'DIV')){
picDescPairArra y[arrayIdx] = nodeStep.id; //store the ID of each one
arrayIdx ++;
}
}
// The above loop omits the last sibling, so add it to the array after
the loop completes if ((nodeStep.clas sName == 'picDescPair') &&
(nodeStep.nodeN ame == 'DIV')){
picDescPairArra y[arrayIdx] = nodeStep.id; //store the ID
}
}
/*Look in the array for the div with the highest z-index or use the last
div, if the z-indexes are all the same. Record it.

Set all the div.z-indexes to a low number (3) Then using the div
preceding the recorded div increase the z-index to a higher number (5).
If it is the first, ignore the instruction. */

var arrayIndexOfHig hestZIndexObj = 0; var lengthOfArray =
picDescPairArra y.length; //last entry is on top (subtract 1 as it's a '0'
based array) var currentlyHighes tZIndexObjId =
picDescPairArra y[lengthOfArray-1]; var currentlyHighes tZIndex =
document.getEle mentById(curren tlyHighestZInde xObjId).style.z Index;
//checking to see if anything is higher than the last item var sameSoFar
= true;
for (var i=0; i <= picDescPairArra y.length-1; i++){
if (document.getEl ementById(picDe scPairArray[i]).style.zIndex >
currentlyHighes tZIndex){
sameSoFar = false;
currentlyHighes tZIndex =
document.getEle mentById(picDes cPairArray[i]).style.zIndex;
currentlyHighes tZIndexObjId = picDescPairArra y[i];
arrayIndexOfHig hestZIndexObj = i;
}else if (sameSoFar){ //the last one through - just in case they're all
}the same level
arrayIndexOfHig hestZIndexObj = i;
}
}
//Set parameters to step in correct direction if (direction == 'back'){
var deltaStep = 1;
var limitingCase = picDescPairArra y.length-1;
} else if (direction == 'forward'){
var deltaStep = -1;
var limitingCase = 0;
}
//if this is not the limiting extent (first or last) item in the array,
change the z-index of all the items to 3 if (arrayIndexOfHi ghestZIndexObj
!= limitingCase){
for (i=0; i <= picDescPairArra y.length-1; i++){
document.getEle mentById(picDes cPairArray[i]).style.zIndex = 3;
}
}
var newHighest = arrayIndexOfHig hestZIndexObj + deltaStep;
document.getEle mentById(picDes cPairArray[newHighest]).style.zIndex = 5;
//------------------
// Stop click event propagation in parent div hierarchy if (document.all)
{
// Code for IE browsers
window.event.ca ncelBubble=true ;
} else if (!document.all && document.getEle mentById) {
// Code for Mozilla browsers
evt.stopPropaga tion();
}
}
}
Jul 20 '05 #1
1 2469
After all that, it turned out to be a typo in the PHP, that meant that the
one of the button's image tags was not properly terminated with closing
angled brackets.

Sorry to waste your time....
Greg (again)

:o) (o: :o) (o: :o) (o: :o) (o:
On Wed, 21 Jan 2004 01:28:48 +0000, Greg wrote:
The following code works fine on Mozilla but generates an error* on IE,
when the button calling the function is pressed and the slideshow is
either on the first slide or last slide. * I can't remember the exact
error and I'm on Linux/Mozilla at the moment, but I think it had a
problem with the object model?!?

The slideshow has a stack of div tags and the buttons are used to change
the z-order. Each div contains two other divs: one with a picture and
one with a description.

All this is generated on the fly in php, from a mySQL database, hence
the DOM parsing to find the appropriate div to bring to the front.

Thanks,

Greg

=============== =======

//The code that calls this function is an image in a table: <img
id='ex2-stepForward' name='stepForwa rd'
src='./images/site/stepForward.gif '
width='24'
height='24'
border='0'
onmouseover="ch angeImages(this .id,
'./images/site/stepForward-over.gif'); return true; "
onmouseout="cha ngeImages(this. id, './images/site/stepForward.gif ');
return true; "
onmousedown="ch angeImages(this .id,
'./images/site/stepForward-down.gif');
return true; "
onmouseup="chan geImages(this.i d, './images/site/stepForward-over.gif');
stepOne(event, this, 'forward'); return true; ">

=============== =============

//Steps back and forward in the stack of image/description containers
//for the group associated with the control pressed function
stepOne(evt, thisExercise, direction){
var nodeStep = thisExercise;
//parse UP the tree by parent
while (nodeStep.class Name != 'maskGroup'){
nodeStep = nodeStep.parent Node;
}
//parse DOWN the tree by sibling
while (nodeStep.class Name != 'picDescPair'){
nodeStep = nodeStep.nextSi bling;
}
//this is the first PicDescPair node
var firstPicDescPai rNode = nodeStep;
//this is the last sibling (We'll parse from firstPicDescPai rNode to
the last sibling looking for other PicDescPairs) var lastSiblingNode =
firstPicDescPai rNode.parentNod e.lastChild; //use an array to store all
the PicDescPairs found var arrayIdx = 0; var picDescPairArra y = new
Array(0);
//store the ID of the first one
picDescPairArra y[arrayIdx] = firstPicDescPai rNode.id; arrayIdx ++; //
loop until the last sibling, looking for more. A DO/WHILE loop might be
preferable? Check limiting case of single nodeStep while (nodeStep !=
lastSiblingNode ){
nodeStep = nodeStep.nextSi bling;
if ((nodeStep.clas sName == 'picDescPair') && (nodeStep.nodeN ame ==
'DIV')){
picDescPairArra y[arrayIdx] = nodeStep.id; //store the ID of each one
arrayIdx ++;
}
}
// The above loop omits the last sibling, so add it to the array after
the loop completes if ((nodeStep.clas sName == 'picDescPair') &&
(nodeStep.nodeN ame == 'DIV')){
picDescPairArra y[arrayIdx] = nodeStep.id; //store the ID
}
}
/*Look in the array for the div with the highest z-index or use the
last div, if the z-indexes are all the same. Record it.

Set all the div.z-indexes to a low number (3) Then using the div
preceding the recorded div increase the z-index to a higher number (5).
If it is the first, ignore the instruction. */

var arrayIndexOfHig hestZIndexObj = 0; var lengthOfArray =
picDescPairArra y.length; //last entry is on top (subtract 1 as it's a
'0' based array) var currentlyHighes tZIndexObjId =
picDescPairArra y[lengthOfArray-1]; var currentlyHighes tZIndex =
document.getEle mentById(curren tlyHighestZInde xObjId).style.z Index;
//checking to see if anything is higher than the last item var
sameSoFar = true;
for (var i=0; i <= picDescPairArra y.length-1; i++){
if (document.getEl ementById(picDe scPairArray[i]).style.zIndex >
currentlyHighes tZIndex){
sameSoFar = false;
currentlyHighes tZIndex =
document.getEle mentById(picDes cPairArray[i]).style.zIndex;
currentlyHighes tZIndexObjId = picDescPairArra y[i];
arrayIndexOfHig hestZIndexObj = i;
}else if (sameSoFar){ //the last one through - just in case they're
}all the same level
arrayIndexOfHig hestZIndexObj = i;
}
}
//Set parameters to step in correct direction if (direction == 'back'){
var deltaStep = 1;
var limitingCase = picDescPairArra y.length-1;
} else if (direction == 'forward'){
var deltaStep = -1;
var limitingCase = 0;
}
//if this is not the limiting extent (first or last) item in the array,
change the z-index of all the items to 3 if
(arrayIndexOfHi ghestZIndexObj != limitingCase){
for (i=0; i <= picDescPairArra y.length-1; i++){
document.getEle mentById(picDes cPairArray[i]).style.zIndex = 3;
}
}
var newHighest = arrayIndexOfHig hestZIndexObj + deltaStep;
document.getEle mentById(picDes cPairArray[newHighest]).style.zIndex = 5;
//------------------
// Stop click event propagation in parent div hierarchy if
(document.all) {
// Code for IE browsers
window.event.ca ncelBubble=true ;
} else if (!document.all && document.getEle mentById) {
// Code for Mozilla browsers
evt.stopPropaga tion();
}
}
}

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
7055
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. Yensao
10
3573
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script language="JavaScript" type="text/javascript"> function show(that) { if (box.style.visibility=='hidden') { that.style.visibility = 'visible'}; }
1
7088
by: Pawe³ Ga³ecki | last post by:
I wrote a following function just for testing purposes: <html> <head> <script> function show(obj) { alert(obj.previousSibling.rowIndex) alert(obj.rowIndex) alert(obj.nextSibling.rowIndex) } </script>
8
2924
by: Nicolás Lichtmaier | last post by:
Hi, some time ago I've written an article about this issue. It explain some differences in Explorer's and Mozilla's JavaScript/DOM. It has recently changed its URL, This is the new one: http://www.reloco.com.ar/mozilla/compat.html Bye! PS: I hope it's useful to someone. I would appreciate any comments and suggestions!
6
13344
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... html file (generated using .NET 2.0 beta2): <form method="post" action="Test2.aspx" id="form1">
38
5170
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please let's us do not go into an "each dot over i" clarification discussion now - however you want to call - you call it ;-) array contains records of...
3
1611
by: jeet_sen | last post by:
Hi, I developed a web page using javascript on Linux machine and tested to work fine on Mozilla. Now I tried to view the page in IE which is returning javascript error. How can I successfully make my compatible with IE too. Please refer to some links or readings where such related problem is dealt with. Is there any checklist for making web...
0
5545
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
7755
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...
0
7992
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. ...
1
7756
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...
0
8048
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6385
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...
1
5571
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...
0
3722
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2183
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
0
1027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.