473,513 Members | 2,403 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='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 2456
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
7027
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. ...
10
3562
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...
1
7086
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) }...
8
2909
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: ...
6
13335
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... ...
38
5147
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...
3
1603
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...
0
5521
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...
0
7264
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,...
0
7166
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7534
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...
0
5689
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,...
1
5094
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...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1601
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 ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
459
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...

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.