472,347 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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='stepForward'
src='./images/site/stepForward.gif'
width='24'
height='24'
border='0'
onmouseover="changeImages(this.id, './images/site/stepForward-over.gif');
return true; "
onmouseout="changeImages(this.id, './images/site/stepForward.gif');
return true; "
onmousedown="changeImages(this.id, './images/site/stepForward-down.gif');
return true; "
onmouseup="changeImages(this.id, './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.className != 'maskGroup'){
nodeStep = nodeStep.parentNode;
}
//parse DOWN the tree by sibling
while (nodeStep.className != 'picDescPair'){
nodeStep = nodeStep.nextSibling;
}
//this is the first PicDescPair node
var firstPicDescPairNode = nodeStep;
//this is the last sibling (We'll parse from firstPicDescPairNode to the
last sibling looking for other PicDescPairs) var lastSiblingNode =
firstPicDescPairNode.parentNode.lastChild; //use an array to store all
the PicDescPairs found var arrayIdx = 0;
var picDescPairArray = new Array(0);
//store the ID of the first one
picDescPairArray[arrayIdx] = firstPicDescPairNode.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.nextSibling;
if ((nodeStep.className == 'picDescPair') && (nodeStep.nodeName ==
'DIV')){
picDescPairArray[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.className == 'picDescPair') &&
(nodeStep.nodeName == 'DIV')){
picDescPairArray[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 arrayIndexOfHighestZIndexObj = 0; var lengthOfArray =
picDescPairArray.length; //last entry is on top (subtract 1 as it's a '0'
based array) var currentlyHighestZIndexObjId =
picDescPairArray[lengthOfArray-1]; var currentlyHighestZIndex =
document.getElementById(currentlyHighestZIndexObjI d).style.zIndex;
//checking to see if anything is higher than the last item var sameSoFar
= true;
for (var i=0; i <= picDescPairArray.length-1; i++){
if (document.getElementById(picDescPairArray[i]).style.zIndex >
currentlyHighestZIndex){
sameSoFar = false;
currentlyHighestZIndex =
document.getElementById(picDescPairArray[i]).style.zIndex;
currentlyHighestZIndexObjId = picDescPairArray[i];
arrayIndexOfHighestZIndexObj = i;
}else if (sameSoFar){ //the last one through - just in case they're all
}the same level
arrayIndexOfHighestZIndexObj = i;
}
}
//Set parameters to step in correct direction if (direction == 'back'){
var deltaStep = 1;
var limitingCase = picDescPairArray.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 (arrayIndexOfHighestZIndexObj
!= limitingCase){
for (i=0; i <= picDescPairArray.length-1; i++){
document.getElementById(picDescPairArray[i]).style.zIndex = 3;
}
}
var newHighest = arrayIndexOfHighestZIndexObj + deltaStep;
document.getElementById(picDescPairArray[newHighest]).style.zIndex = 5;
//------------------
// Stop click event propagation in parent div hierarchy if (document.all)
{
// Code for IE browsers
window.event.cancelBubble=true;
} else if (!document.all && document.getElementById) {
// Code for Mozilla browsers
evt.stopPropagation();
}
}
}
Jul 20 '05 #1
1 2398
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='stepForward'
src='./images/site/stepForward.gif'
width='24'
height='24'
border='0'
onmouseover="changeImages(this.id,
'./images/site/stepForward-over.gif'); return true; "
onmouseout="changeImages(this.id, './images/site/stepForward.gif');
return true; "
onmousedown="changeImages(this.id,
'./images/site/stepForward-down.gif');
return true; "
onmouseup="changeImages(this.id, './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.className != 'maskGroup'){
nodeStep = nodeStep.parentNode;
}
//parse DOWN the tree by sibling
while (nodeStep.className != 'picDescPair'){
nodeStep = nodeStep.nextSibling;
}
//this is the first PicDescPair node
var firstPicDescPairNode = nodeStep;
//this is the last sibling (We'll parse from firstPicDescPairNode to
the last sibling looking for other PicDescPairs) var lastSiblingNode =
firstPicDescPairNode.parentNode.lastChild; //use an array to store all
the PicDescPairs found var arrayIdx = 0; var picDescPairArray = new
Array(0);
//store the ID of the first one
picDescPairArray[arrayIdx] = firstPicDescPairNode.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.nextSibling;
if ((nodeStep.className == 'picDescPair') && (nodeStep.nodeName ==
'DIV')){
picDescPairArray[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.className == 'picDescPair') &&
(nodeStep.nodeName == 'DIV')){
picDescPairArray[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 arrayIndexOfHighestZIndexObj = 0; var lengthOfArray =
picDescPairArray.length; //last entry is on top (subtract 1 as it's a
'0' based array) var currentlyHighestZIndexObjId =
picDescPairArray[lengthOfArray-1]; var currentlyHighestZIndex =
document.getElementById(currentlyHighestZIndexObjI d).style.zIndex;
//checking to see if anything is higher than the last item var
sameSoFar = true;
for (var i=0; i <= picDescPairArray.length-1; i++){
if (document.getElementById(picDescPairArray[i]).style.zIndex >
currentlyHighestZIndex){
sameSoFar = false;
currentlyHighestZIndex =
document.getElementById(picDescPairArray[i]).style.zIndex;
currentlyHighestZIndexObjId = picDescPairArray[i];
arrayIndexOfHighestZIndexObj = i;
}else if (sameSoFar){ //the last one through - just in case they're
}all the same level
arrayIndexOfHighestZIndexObj = i;
}
}
//Set parameters to step in correct direction if (direction == 'back'){
var deltaStep = 1;
var limitingCase = picDescPairArray.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
(arrayIndexOfHighestZIndexObj != limitingCase){
for (i=0; i <= picDescPairArray.length-1; i++){
document.getElementById(picDescPairArray[i]).style.zIndex = 3;
}
}
var newHighest = arrayIndexOfHighestZIndexObj + deltaStep;
document.getElementById(picDescPairArray[newHighest]).style.zIndex = 5;
//------------------
// Stop click event propagation in parent div hierarchy if
(document.all) {
// Code for IE browsers
window.event.cancelBubble=true;
} else if (!document.all && document.getElementById) {
// Code for Mozilla browsers
evt.stopPropagation();
}
}
}

Jul 20 '05 #2

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

Similar topics

34
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...
10
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...
1
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)...
8
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...
6
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...
38
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...
3
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...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.